Core Data observer exception in 10.6
Core Data observer exception in 10.6
- Subject: Core Data observer exception in 10.6
- From: David Sinclair <email@hidden>
- Date: Sat, 29 Aug 2009 13:48:09 -0700
Hi,
In a Core Data-based app that works fine in 10.5.x, I now get an
exception as follows in 10.6 when opening a document. It targets
10.5, and the same exception occurs when rebuilding on 10.6 (still
targeting 10.5, but also when targeting 10.6).
I don't register or unregister any observers myself, and the exception
occurs without touching any of my code. What's going on?
NSRangeException: Cannot remove an observer <NSKeyValueObservance
0x15476c0> for the key path "richText" from <TextEntity 0x1546380>
because it is not registered as an observer.
1 +[NSException raise:format:arguments:] (in CoreFoundation) + 136
2 +[NSException raise:format:] (in CoreFoundation) + 58
3 -[NSObject(NSKeyValueObserverRegistration)
_removeObserver:forProperty:] (in Foundation) + 765
4 -[NSObject(NSKeyValueObserverRegistration)
removeObserver:forKeyPath:] (in Foundation) + 176
5 -[NSKeyValueNestedProperty
object:didRemoveObservance:recurse:] (in Foundation) + 544
6 -[NSObject(NSKeyValueObserverRegistration)
_removeObserver:forProperty:] (in Foundation) + 453
7 -[NSObject(NSKeyValueObserverRegistration)
removeObserver:forKeyPath:] (in Foundation) + 176
8 -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForModelObject:] (in
AppKit) + 228
9 -[_NSModelObservingTracker clearAllModelObjectObserving] (in
AppKit) + 341
10 -[_NSModelObservingTracker
setIndexReferenceModelObjectArray:clearAllModelObjectObserving:] (in
AppKit) + 51
11 -[NSArrayController _setObjects:] (in AppKit) + 196
12 -[NSArrayController
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis
:] (in AppKit) + 510
13 -[NSArrayController rearrangeObjects] (in AppKit) + 133
14 -[NSArrayController
observeValueForKeyPath:ofObject:change:context:] (in AppKit) + 338
15 NSKeyValueDidChange (in Foundation) + 377
16 -[NSObject(NSKeyValueObservingPrivate)
_didChangeValuesForKeys:] (in Foundation) + 565
17 _PFFaultHandlerFulfillFault (in CoreData) + 1921
18 _PFFaultHandlerLookupRow (in CoreData) + 1573
19 -[NSFaultHandler fulfillFault:withContext:] (in CoreData) + 39
20 _PF_FulfillDeferredFault (in CoreData) + 193
21 _sharedIMPL_pvfk_core (in CoreData) + 65
22 -[NSManagedObject(_PFDynamicAccessorsAndPropertySupport)
_genericValueForKey:withIndex:flags:] (in CoreData) + 79
23 -[NSManagedObject valueForKey:] (in CoreData) + 244
24 -[NSKeyValueNestedProperty object:didAddObservance:recurse:]
(in Foundation) + 240
25 -[NSObject(NSKeyValueObserverRegistration)
_addObserver:forProperty:options:context:] (in Foundation) + 812
26 -[NSObject(NSKeyValueObserverRegistration)
addObserver:forKeyPath:options:context:] (in Foundation) + 565
27 -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForKeyPath:ofModelObject:]
(in AppKit) + 134
28 -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForModelObject:] (in
AppKit) + 228
29 -[_NSModelObservingTracker _startObservingModelObject:] (in
AppKit) + 418
30 -[_NSModelObservingTracker
startObservingModelObjectsAtReferenceIndexes:] (in AppKit) + 333
31 -[NSArrayController
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis
:] (in AppKit) + 510
32 -[NSArrayController setContent:] (in AppKit) + 889
33 -[NSArrayController(NSManagedController)
_performFetchWithRequest:merge:error:] (in AppKit) + 501
34 -[NSObjectController(NSManagedController)
fetchWithRequest:merge:error:] (in AppKit) + 209
35 -[NSObjectController(NSManagedController)
_executeFetch:didCommitSuccessfully:actionSender:] (in AppKit) + 106
36 _NSSendCommitEditingSelector (in AppKit) + 339
37 -[NSController _controllerEditor:didCommit:contextInfo:] (in
AppKit) + 216
38 __invoking___ (in CoreFoundation) + 29
39 -[NSInvocation invoke] (in CoreFoundation) + 136
40 -[NSInvocation invokeWithTarget:] (in CoreFoundation) + 72
41 __NSFireDelayedPerform (in Foundation) + 537
42 __CFRunLoopRun (in CoreFoundation) + 6846
Immediately after that exception is a related one, which sounds more
helpful, but still doesn't make sense to me:
NSInternalInconsistencyException: Cannot remove an observer
<NSArrayController 0x1452df0> for the key path "text.richText" from
<ChapterEntity 0x1487b40>, most likely because the value for the key
"text" has changed without an appropriate KVO notification being sent.
Check the KVO-compliance of the ChapterEntity class.
1 +[NSException raise:format:arguments:] (in CoreFoundation) + 136
2 +[NSException raise:format:] (in CoreFoundation) + 58
3 -[NSKeyValueNestedProperty
object:didRemoveObservance:recurse:] (in Foundation) + 457
4 -[NSObject(NSKeyValueObserverRegistration)
_removeObserver:forProperty:] (in Foundation) + 453
5 -[NSObject(NSKeyValueObserverRegistration)
removeObserver:forKeyPath:] (in Foundation) + 176
6 -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForModelObject:] (in
AppKit) + 228
7 -[_NSModelObservingTracker clearAllModelObjectObserving] (in
AppKit) + 341
8 -[_NSModelObservingTracker
setIndexReferenceModelObjectArray:clearAllModelObjectObserving:] (in
AppKit) + 51
9 -[NSArrayController _setObjects:] (in AppKit) + 196
10 -[NSArrayController
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis
:] (in AppKit) + 510
11 -[NSArrayController rearrangeObjects] (in AppKit) + 133
12 -[NSArrayController
observeValueForKeyPath:ofObject:change:context:] (in AppKit) + 338
13 NSKeyValueDidChange (in Foundation) + 377
14 -[NSObject(NSKeyValueObservingPrivate)
_didChangeValuesForKeys:] (in Foundation) + 565
15 _PFFaultHandlerFulfillFault (in CoreData) + 1921
16 _PFFaultHandlerLookupRow (in CoreData) + 1573
17 -[NSFaultHandler fulfillFault:withContext:] (in CoreData) + 39
18 _PF_FulfillDeferredFault (in CoreData) + 193
19 _sharedIMPL_pvfk_core (in CoreData) + 65
20 -[NSManagedObject(_PFDynamicAccessorsAndPropertySupport)
_genericValueForKey:withIndex:flags:] (in CoreData) + 79
21 -[NSManagedObject valueForKey:] (in CoreData) + 244
22 -[NSKeyValueNestedProperty object:didAddObservance:recurse:]
(in Foundation) + 240
23 -[NSObject(NSKeyValueObserverRegistration)
_addObserver:forProperty:options:context:] (in Foundation) + 812
24 -[NSObject(NSKeyValueObserverRegistration)
addObserver:forKeyPath:options:context:] (in Foundation) + 565
25 -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForKeyPath:ofModelObject:]
(in AppKit) + 134
26 -[_NSModelObservingTracker
_registerOrUnregister:observerNotificationsForModelObject:] (in
AppKit) + 228
27 -[_NSModelObservingTracker _startObservingModelObject:] (in
AppKit) + 418
28 -[_NSModelObservingTracker
startObservingModelObjectsAtReferenceIndexes:] (in AppKit) + 333
29 -[NSArrayController
_arrangeObjectsWithSelectedObjects:avoidsEmptySelection:operationsMask:useBasis
:] (in AppKit) + 510
30 -[NSArrayController setContent:] (in AppKit) + 889
31 -[NSArrayController(NSManagedController)
_performFetchWithRequest:merge:error:] (in AppKit) + 501
32 -[NSObjectController(NSManagedController)
fetchWithRequest:merge:error:] (in AppKit) + 209
33 -[NSObjectController(NSManagedController)
_executeFetch:didCommitSuccessfully:actionSender:] (in AppKit) + 106
34 _NSSendCommitEditingSelector (in AppKit) + 339
35 -[NSController _controllerEditor:didCommit:contextInfo:] (in
AppKit) + 216
36 __invoking___ (in CoreFoundation) + 29
37 -[NSInvocation invoke] (in CoreFoundation) + 136
38 -[NSInvocation invokeWithTarget:] (in CoreFoundation) + 72
39 __NSFireDelayedPerform (in Foundation) + 537
40 __CFRunLoopRun (in CoreFoundation) + 6846
41 CFRunLoopRunSpecific (in CoreFoundation) + 452
42 CFRunLoopRunInMode (in CoreFoundation) + 97
43 RunCurrentEventLoopInMode (in HIToolbox) + 392
44 ReceiveNextEventCommon (in HIToolbox) + 354
45 BlockUntilNextEventMatchingListInMode (in HIToolbox) + 81
46 _DPSNextEvent (in AppKit) + 847
47 -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 156
48 -[NSApplication run] (in AppKit) + 821
49 NSApplicationMain (in AppKit) + 574
50 main (in Narrator) (main.m:14)
ChapterEntity is:
@interface ChapterEntity : NSManagedObject
{
}
@property(copy) NSString *name;
@property(copy) NSImage *tableImage;
@property(assign) TextEntity *text;
@property(assign) DocumentEntity *document;
@end
@implementation ChapterEntity
@dynamic name, tableImage, text, document;
- (void)awakeFromInsert;
{
[super awakeFromInsert];
NSManagedObjectContext *managedObjectContext = [self
managedObjectContext];
self.tableImage = [NSImage imageNamed:@"GenericDocument"];
self.text = [NSEntityDescription
insertNewObjectForEntityForName:@"Text"
inManagedObjectContext:managedObjectContext];
}
@end
But the exception occurs even if I comment out the contents of -
awakeFromInsert.
And TextEntity has just dynamic properties, no code.
Any ideas?
--
David Sinclair, Dejal Systems, LLC - email@hidden
Dejal blog - http://www.dejal.com/blog/
Cocoa code - http://www.dejal.com/developer/
Twitter - http://twitter.com/dejal/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden