Entity with name '(null)'


#1

I thought I got all the bindings right but I get this error on starting the program. Any suggestions on where to look? Thanks.

[Switching to process 13710 thread 0x0]
2011-12-24 10:45:26.180 CarLot[13710:407] Cannot perform operation since entity with name ‘(null)’ cannot be found
2011-12-24 10:45:26.183 CarLot[13710:407] (
0 CoreFoundation 0x00007fff8544f286 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8a6afd5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8544f0ba +[NSException raise:format:arguments:] + 106
3 CoreFoundation 0x00007fff8544f044 +[NSException raise:format:] + 116
4 AppKit 0x00007fff8d8aa80b -[_NSManagedProxy _entity] + 149
5 AppKit 0x00007fff8d8aa4db -[_NSManagedProxy fetchRequestWithSortDescriptors:limit:] + 93
6 AppKit 0x00007fff8d69ca09 -[NSArrayController(NSManagedController) defaultFetchRequest] + 89
7 AppKit 0x00007fff8d8ac626 -[NSObjectController(NSManagedController) _fetchRequestForPerformingFetch] + 18
8 AppKit 0x00007fff8d8ac82e -[NSObjectController(NSManagedController) _executeFetch:didCommitSuccessfully:actionSender:] + 68
9 AppKit 0x00007fff8da8cb05 _NSSendCommitEditingSelector + 54
10 AppKit 0x00007fff8d74ab7e -[NSController controllerEditor:didCommit:contextInfo:] + 188
11 CoreFoundation 0x00007fff8544120c invoking
+ 140
12 CoreFoundation 0x00007fff854410a4 -[NSInvocation invoke] + 132
13 CoreFoundation 0x00007fff85441274 -[NSInvocation invokeWithTarget:] + 52
14 Foundation 0x00007fff8a78a25a __NSFireDelayedPerform + 392
15 CoreFoundation 0x00007fff85403f84 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
16 CoreFoundation 0x00007fff85403ad6 __CFRunLoopDoTimer + 534
17 CoreFoundation 0x00007fff853e4471 __CFRunLoopRun + 1617
18 CoreFoundation 0x00007fff853e3ae6 CFRunLoopRunSpecific + 230
19 HIToolbox 0x00007fff8c2e03d3 RunCurrentEventLoopInMode + 277
20 HIToolbox 0x00007fff8c2e758f ReceiveNextEventCommon + 181
21 HIToolbox 0x00007fff8c2e74ca BlockUntilNextEventMatchingListInMode + 62
22 AppKit 0x00007fff8d3d73f1 _DPSNextEvent + 659
23 AppKit 0x00007fff8d3d6cf5 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
24 AppKit 0x00007fff8d3d362d -[NSApplication run] + 470
25 AppKit 0x00007fff8d65280c NSApplicationMain + 867
26 CarLot 0x0000000100000c62 main + 34
27 CarLot 0x0000000100000c34 start + 52
28 ??? 0x0000000000000003 0x0 + 3
)
Program ended with exit code: 0


#2

It seems I left out the step on page 180, setting the Entity Name to Car.


#3

I have the Kindle edition (4th edition) and not 100% sure where your page 180 would be there?

Just below Figure 11.1 it says:

“In the new project, open MyDocument.xcdatamodeld. Click the Add Entity button at the bottom left of the editor to create a new entity. Name the entity Car.”

Is that where you were talking about?

I am getting a nearly identical error, but I did name my entity “Car” and can see it in my project right now. My error looks like:

2012-12-01 07:46:27.627 CarLot[415:303] Cannot perform operation since entity with name ‘(null)’ cannot be found
2012-12-01 07:46:27.630 CarLot[415:303] (
0 CoreFoundation 0x00007fff8ad980a6 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff84f053f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff8ad97e7c +[NSException raise:format:] + 204
3 AppKit 0x00007fff8311f677 -[_NSManagedProxy _entity] + 144
4 AppKit 0x00007fff8311f52a -[_NSManagedProxy fetchRequestWithSortDescriptors:limit:] + 95
5 AppKit 0x00007fff835f4560 -[NSObjectController(NSManagedController) _executeFetch:didCommitSuccessfully:actionSender:] + 73
6 AppKit 0x00007fff837a836a _NSSendCommitEditingSelector + 58
7 AppKit 0x00007fff834a6e24 -[NSController controllerEditor:didCommit:contextInfo:] + 190
8 CoreFoundation 0x00007fff8ad8b63c invoking
+ 140
9 CoreFoundation 0x00007fff8ad8b4d7 -[NSInvocation invoke] + 263
10 CoreFoundation 0x00007fff8ad8b6a9 -[NSInvocation invokeWithTarget:] + 57
11 Foundation 0x00007fff8434edb5 __NSFireDelayedPerform + 358
12 CoreFoundation 0x00007fff8ad54da4 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
13 CoreFoundation 0x00007fff8ad548bd __CFRunLoopDoTimer + 557
14 CoreFoundation 0x00007fff8ad3a099 __CFRunLoopRun + 1513
15 CoreFoundation 0x00007fff8ad396b2 CFRunLoopRunSpecific + 290
16 HIToolbox 0x00007fff81fb50a4 RunCurrentEventLoopInMode + 209
17 HIToolbox 0x00007fff81fb4d84 ReceiveNextEventCommon + 166
18 HIToolbox 0x00007fff81fb4cd3 BlockUntilNextEventMatchingListInMode + 62
19 AppKit 0x00007fff831b5613 _DPSNextEvent + 685
20 AppKit 0x00007fff831b4ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
21 AppKit 0x00007fff831ac283 -[NSApplication run] + 517
22 AppKit 0x00007fff83150cb6 NSApplicationMain + 869
23 CarLot 0x0000000100000c82 main + 34
24 libdyld.dylib 0x00007fff888967e1 start + 0
25 ??? 0x0000000000000003 0x0 + 3
)

This is third time I have tried to build this project with Xcode 4.5.2 and is getting frustrating. Is there anyway (asking the moderator or anyone who knows) to debug this and figure out what it is looking for that I apparently did not supply correctly? Can I get a working copy (with Xcode 4.5.2) to compare?

Thanks,

lwk


#4

I just had the same problem i.e. I was getting the error message:

“2012-12-04 13:10:23.730 CarLot[1565:303] Cannot perform operation since entity with name ‘(null)’ cannot be found
2012-12-04 13:10:23.736 CarLot[1565:303] (…”

I’m also using the kindle version of the 4th Edition (and Xcode 4.5.2). Loc 3669 of 10487 on my iPad 2 - directly underneath figure 11.3 - if that’s any help.

The bit that I missed was “With the array controller still selected, in the Attributes Inspector under Object Controller section, set Mode to Entity Name and the entity name to Car.

Once I had set the entity name to car in the object controller section everything worked fine.

Regards

Matt


#5

I overcame this another way, but none the less, same applies.

  1. Create a subclass of NSManagedObject called Car (using the editor)
  2. Included the .h of it in my CarArrauController.m
    used this code:
#import "CarArrayController.h"
#import "Car.h"

@implementation CarArrayController
@synthesize tableView;


-(id)newObject{
    id newObj = [super newObject];
    NSDate *now = [NSDate date];
    [newObj setValue:now forKey:@"datePurchased"];
    [newObj setValue:[NSNumber numberWithInt:5] forKey:@"condition"];
    return newObj;
}

-(IBAction)add:(id)sender{
    NSWindow *w = [tableView window];
    BOOL editingEnded = [w makeFirstResponder:w];
    if (!editingEnded){
        NSLog(@"There was an error ending the editing!");
        return;
    }
    
    Car *c = [self newObject];
    [self addObject:c];
    
    [self rearrangeObjects];
    
    NSArray *a = [self arrangedObjects];
    
    NSUInteger row = [a indexOfObjectIdenticalTo:c];
    
    [tableView editColumn:0 row:row withEvent:nil select:YES];
}


@end

I must admit though, took some mucking about and googling the NSNull error that kept appearing! Weird thing tho is that I had the mode correct but still had this error :-/

Another thing I noticed is that somewher XCode was caching builds… I had to Project -> Clean then Project -> Build alot to get an uncached build.


#6

@lwk, what he was talking about is in InterfaceBuilder. CLick on the NSArrayController in MyDocument.xib, then click on the Attributes Inspector, change the MODE of the NSArrayController from Class to Entity, set the entity name to Car and tick Prepares context.


#7

This thread was quite helpful to me, but I experienced a little catch to the suggested fix which ultimately worked for me. After entering ‘Car’ as the entity name, I failed to deselect the text entry field, and despite saving and cleaning, still got the same result. Only after clicking elsewhere in the interface did Xcode recognize my change. This little quirk of Xcode’s functionality has caught me before, so I thought it might be worth a mention.


#8

I had the same issue. I forgot to the the entity name in the Attributes Inspector of the NSArrayController. Hope it helps anyone else.