Hi.
In my NSPersistentDocument based application (SDK 10.9, Deployment 10.8 XCode
5.1.1) The main document window is loaded from a .xib file. Recently I started
to experience the following ill behavior.
If I open an old existing document, all is well. I can manipulate, add
entities, remove, and otherwise manipulate my document. I can save (and
autosave) without problem.
But... If I try to create a new empty document, I experience a bad exception
immediately after trying to save the first time, or if AutoSave's are allowed
-- the exception is raised without me touching the keyboard, a second or two
after launching the application and seeing the document window.
Setting up a symbolic breakpoint to catch exceptions, I discovered the
exception happens in the following NSPersistentDocument method:
- (BOOL)configurePersistentStoreCoordinatorForURL:(NSURL *)url ofType:(NSString
*)fileType modelConfiguration:(NSString *)configuration
storeOptions:(NSDictionary *)storeOptions error:(NSError **)error
NS_AVAILABLE_MAC(10_5);
The exception:
2014-05-22 23:06:16.729 PlanktoMetrix-II[88475:303] Cannot perform operation
since entity with name '(null)' cannot be found
2014-05-22 23:06:16.735 PlanktoMetrix-II[88475:303] (
0 CoreFoundation 0x00007fff8923db06
__exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8eee73f0
objc_exception_throw + 43
2 CoreFoundation 0x00007fff8923d8dc
+[NSException raise:format:] + 204
3 AppKit 0x00007fff8dff3587
-[_NSManagedProxy _entity] + 144
4 AppKit 0x00007fff8dff343a
-[_NSManagedProxy fetchRequestWithSortDescriptors:limit:] + 95
5 AppKit 0x00007fff8e4c8d2c
-[_NSManagedProxy _storesDidChange:] + 125
6 CoreFoundation 0x00007fff891efeda
_CFXNotificationPost + 2554
7 Foundation 0x00007fff8ebbf796
-[NSNotificationCenter postNotificationName:object:userInfo:] + 64
8 CoreData 0x00007fff8dbaaced
-[NSPersistentStoreCoordinator(_NSInternalMethods)
_postStoresChangedNotificationsForStores:changeKey:options:] + 253
9 CoreData 0x00007fff8db9c516
-[NSPersistentStoreCoordinator
addPersistentStoreWithType:configuration:URL:options:error:] + 4006
10 AppKit 0x00007fff8e4e9cf8
-[NSPersistentDocument
configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:]
+ 1567
11 PlanktoMetrix-II 0x000000010003bf74
-[PMXDocument
configurePersistentStoreCoordinatorForURL:ofType:modelConfiguration:storeOptions:error:]
+ 324
12 AppKit 0x00007fff8e76bf6f
-[NSPersistentDocument(NSDeprecatedInternal)
_configurePersistentStoreCoordinatorForURL:ofType:error:] + 159
13 AppKit 0x00007fff8e4ea35c
-[NSPersistentDocument
writeToURL:ofType:forSaveOperation:originalContentsURL:error:] + 362
14 AppKit 0x00007fff8df602ca -[NSDocument
_writeSafelyToURL:ofType:forSaveOperation:forceTemporaryDirectory:error:] + 618
15 AppKit 0x00007fff8df60054 -[NSDocument
_writeSafelyToURL:ofType:forSaveOperation:error:] + 28
16 AppKit 0x00007fff8df5fbd9 -[NSDocument
writeSafelyToURL:ofType:forSaveOperation:error:] + 348
17 AppKit 0x00007fff8e4ebcb1
-[NSPersistentDocument writeSafelyToURL:ofType:forSaveOperation:error:] + 957
18 AppKit 0x00007fff8df5f377
__block_global_90 + 76
19 AppKit 0x00007fff8df6caef
__block_global_97 + 242
20 AppKit 0x00007fff8df6c9ee
__block_global_96 + 339
21 AppKit 0x00007fff8e3a8da0
__block_global_89 + 1533
22 Foundation 0x00007fff8eba4bce
-[NSFileCoordinator(NSPrivate)
_invokeAccessor:orDont:thenRelinquishAccessClaimForID:] + 229
23 Foundation 0x00007fff8eb8791a
-[NSFileCoordinator(NSPrivate)
_coordinateWritingItemAtURL:options:error:byAccessor:] + 705
24 AppKit 0x00007fff8df5ef83 -[NSDocument
_fileCoordinator:coordinateReadingContentsAndWritingItemAtURL:byAccessor:] + 362
25 AppKit 0x00007fff8df5ed07
__66-[NSDocument
saveToURL:ofType:forSaveOperation:completionHandler:]_block_invoke_0 + 920
26 AppKit 0x00007fff8df598a9 -[NSDocument
continueFileAccessUsingBlock:] + 222
27 AppKit 0x00007fff8df59472 -[NSDocument
_performFileAccessOnMainThread:usingBlock:] + 589
28 AppKit 0x00007fff8df5e117 -[NSDocument
performAsynchronousFileAccessUsingBlock:] + 484
29 AppKit 0x00007fff8df5e960 -[NSDocument
saveToURL:ofType:forSaveOperation:completionHandler:] + 151
30 AppKit 0x00007fff8e3a53b4
__block_global_66 + 175
31 AppKit 0x00007fff8df6e5ca -[NSDocument
_commitEditingThenContinue:] + 335
32 AppKit 0x00007fff8e4e8cea
__62-[NSPersistentDocument
_documentEditor:didCommit:withContext:]_block_invoke_0 + 53
33 CoreFoundation 0x00007fff891facd2
__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 18
34 CoreFoundation 0x00007fff891bb47f
__CFRunLoopDoBlocks + 255
35 CoreFoundation 0x00007fff891dfc7c
__CFRunLoopRun + 1948
36 CoreFoundation 0x00007fff891df0e2
CFRunLoopRunSpecific + 290
37 HIToolbox 0x00007fff8d0a7eb4
RunCurrentEventLoopInMode + 209
38 HIToolbox 0x00007fff8d0a7b94
ReceiveNextEventCommon + 166
39 HIToolbox 0x00007fff8d0a7ae3
BlockUntilNextEventMatchingListInMode + 62
40 AppKit 0x00007fff8e089533
_DPSNextEvent + 685
41 AppKit 0x00007fff8e088df2
-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
42 AppKit 0x00007fff8e0801a3
-[NSApplication run] + 517
43 AppKit 0x00007fff8e024bd6
NSApplicationMain + 869
44 PlanktoMetrix-II 0x0000000100008172 main + 34
45 libdyld.dylib 0x00007fff916c97e1 start + 0
46 ??? 0x0000000000000003 0x0 + 3
)
After trying everything I could -- I went to Rabbi-Google, and found the
following CoreData TroubleShooting item from Apple:
--------------
Cannot save documents because entity is null
Problem: You have Core Data document-based application that is unable to save.
When you try to save the document you get an exception:
"Exception raised during posting of notification. Ignored. exception: Cannot
perform operation since entity with name 'Wxyz' cannot be found"
Cause: This error is emitted by an instance of NSObjectController (or one of
its subclasses) that is set in Entity mode but can’t access the entity
description in the managed object model associated with the entity name
specified in Interface Builder. In short, you have a controller in entity mode
with an invalid entity name.
Remedy: Select in turn each of your controllers in Interface Builder, and press
Command-1 to show the inspector. For each controller, ensure you have a valid
entity name in the "Entity Name" field at the top.
--------------
So I went forward to verify there is no empty entity name in each and every
ObjectController (they all are NSArrayControllers) in all my .xib files, and
all those configured for "Entity" mode DO have their correct and right
entities. Otherwise --- I wouldn't be able to manipulate and save old existing
documents.
I'm really foxed here --- how can the same stuff work with old doc, but fail
trying to create a new one? There are no validation errors, because I have NO
ENTITIES in the model. I verified that my context is clean in debug (both
insertedObjects, updatedObjects and deletedObjects of the arrayController are
OK too.
any hint or advise will be deeply appreciated.
Motti Shneor
e-mail: [email protected]
_______________________________________________
Cocoa-dev mailing list ([email protected])
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]