Irony

Discussion in 'Mac Programming' started by Macula, Jun 22, 2010.

  1. Macula macrumors 6502

    Macula

    Joined:
    Oct 23, 2006
    Location:
    All over the place
    #1
    This is really ironic—I am encountering my first serious difficulty with the Hillegass book at chapter 11, the first application that involves no manual coding! :eek:

    As you may recall, this is the CarLot application, a first exercise in CoreData design using bindings.

    I (think I) followed the instructions closely and get no compilation errors (no congratulations due as I didn't write a single line of code).

    However, the document window never even appears and I get the following runtime error:

    Code:
    2010-06-22 20:58:57.528 CarLot[10574:a0f] [<NSArrayController 0x100680b70> valueForUndefinedKey:]: this class is not key value coding-compliant for the key makeModel.
    Worse still, when I select the [File > New] menu command, hell breaks loose:

    Code:
    2010-06-22 20:59:22.372 CarLot[10574:a0f] HIToolbox: ignoring exception '[<NSArrayController 0x100655b50> valueForUndefinedKey:]: this class is not key value coding-compliant for the key makeModel.' that raised inside Carbon event dispatch
    (
    	0   CoreFoundation                      0x00007fff88cbfcc4 __exceptionPreprocess + 180
    	1   libobjc.A.dylib                     0x00007fff887350f3 objc_exception_throw + 45
    	2   CoreFoundation                      0x00007fff88d17999 -[NSException raise] + 9
    	3   Foundation                          0x00007fff81e36172 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 245
    	4   Foundation                          0x00007fff81d653d1 -[NSObject(NSKeyValueCoding) valueForKey:] + 420
    	5   Foundation                          0x00007fff81d68d14 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 226
    	6   AppKit                              0x00007fff830f7fb2 -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 171
    	7   AppKit                              0x00007fff83419dd1 -[NSDisplayPatternBinder _adjustObject:mode:triggerRedisplay:] + 240
    	8   AppKit                              0x00007fff83418f19 -[NSDisplayPatternBinder _observeValueForKeyPath:ofObject:context:] + 121
    	9   AppKit                              0x00007fff830eae7b -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 557
    	10  AppKit                              0x00007fff830c7992 -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1172
    	11  AppKit                              0x00007fff830c5cd9 loadNib + 226
    	12  AppKit                              0x00007fff830c51e9 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 248
    	13  AppKit                              0x00007fff831437c9 -[NSWindowController loadWindow] + 233
    	14  AppKit                              0x00007fff830ea199 -[NSWindowController window] + 82
    	15  AppKit                              0x00007fff832fe399 -[NSWindowController showWindow:] + 47
    	16  AppKit                              0x00007fff832cfe14 -[NSDocument showWindows] + 98
    	17  AppKit                              0x00007fff832ce673 -[NSDocumentController openUntitledDocumentAndDisplay:error:] + 340
    	18  AppKit                              0x00007fff832ce4ee -[NSDocumentController newDocument:] + 33
    	19  AppKit                              0x00007fff83259152 -[NSApplication sendAction:to:from:] + 95
    	20  AppKit                              0x00007fff8327d6be -[NSMenuItem _corePerformAction] + 365
    	21  AppKit                              0x00007fff8327d428 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 121
    	22  AppKit                              0x00007fff8350141d -[NSMenu _internalPerformActionForItemAtIndex:] + 35
    	23  AppKit                              0x00007fff833b3217 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 136
    	24  AppKit                              0x00007fff8325fc14 NSSLMMenuEventHandler + 321
    	25  HIToolbox                           0x00007fff88d8c997 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1002
    	26  HIToolbox                           0x00007fff88d8bee6 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 395
    	27  HIToolbox                           0x00007fff88da9ba9 SendEventToEventTarget + 45
    	28  HIToolbox                           0x00007fff88dd8cd1 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 387
    	29  HIToolbox                           0x00007fff88e05b06 SendMenuCommandWithContextAndModifiers + 56
    	30  HIToolbox                           0x00007fff88e05abe SendMenuItemSelectedEvent + 101
    	31  HIToolbox                           0x00007fff88e059be _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 150
    	32  HIToolbox                           0x00007fff88de6cb3 _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 467
    	33  HIToolbox                           0x00007fff88de6408 _HandleMenuSelection2 + 453
    	34  AppKit                              0x00007fff83130c39 _NSHandleCarbonMenuEvent + 236
    	35  AppKit                              0x00007fff8310474e _DPSNextEvent + 1908
    	36  AppKit                              0x00007fff83103bed -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
    	37  AppKit                              0x00007fff830c98d3 -[NSApplication run] + 395
    	38  AppKit                              0x00007fff830c25f8 NSApplicationMain + 364
    	39  CarLot                              0x0000000100000e0c main + 33
    	40  CarLot                              0x0000000100000d14 start + 52
    )
    Any idea what could be wrong? I checked my model key paths in the Interface Builder, and they seem correct to me.

    I also tried compiling both 10.5 and 10.6 targets—no difference whatsoever.

    Thank you very much.
     
  2. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #2
    It's almost certainly a typo in one of your key paths. A capitalization error, or either making something that should be singular plural, or vice-versa. I know this because in your stack-trace it's trying to find a value for an "undefined key" which means you've almost certainly misspelled it, or defined it improperly in your code (since this example has no code, it's a pretty sure bet where your problem is).

    Edit: I should add that you should title your threads so that they can be more helpful to others doing a search later.
     
  3. chrono1081 macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #3
    Did you try checking the books website to make sure there are no errors in the book?

    Sadly 99.999% of computer programming books have errors in them (and thats probably an accurate statistic).

    Usually to avoid frustration I go check the books website before I start the book. Hopefully this is the case and its not something on your end.
     
  4. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #4
    Unfortunately I can't tell you what you have forgotten to bind or set up in the NSArrayController.

    I have completed that book and that project works fine. You can download the completed projects from the Big Nerd Ranch.

    I am going to go out of a limb here and state with 99.9% accuracy, you have typed something in wrong, or more likely, you have bound the field to the wrong controller or data column, and the keypath is going to be wrong.

    Simple rules are as follows. NSTable always binds on arrangedObjects.
    NSTextBox or similar always binds on selection, never arrangedObjects.

    Slowly go through the book chapter again, and make sure you have selected the correct field, etc when making the bindings.
     

Share This Page