Re: What are the conditions for NSManagedObjectContextObjectsDidChangeNotification to get posted?
Re: What are the conditions for NSManagedObjectContextObjectsDidChangeNotification to get posted?
- Subject: Re: What are the conditions for NSManagedObjectContextObjectsDidChangeNotification to get posted?
- From: Jim McGowan <email@hidden>
- Date: Fri, 17 Jan 2014 11:17:55 +0800
On 17 Jan, 2014, at 12:02 am, Mike Abdullah <email@hidden> wrote:
>
> - Does NSManagedObjectContextObjectsDidChangeNotification ever get posted *not* as a result of -processPendingChanges?
> - When you start seeing the problematic behaviour, is -processPendingChanges still being called, but not firing off the notification? Or is it also not being called itself?
>
When the issue starts, -processPendingChanges isn’t being called by the framework, and neither is the notification being posted. But debugging this revealed some further strangeness.
It seems that during editing the notification is not posted from -processPendingChanges, rather both -processPendingChanges and the posting of the notification are happening in a private method -[NSManagedObjectContext(_NSInternalNotificationHandling) _processEndOfEventNotification:], which is called in response the the NSUndoManager sending out a notification. You can see this in the stacks below: It looks like after the framework calls -processPendingChanges, it then calls a method _processRecentChanges, which sends the notification.
#0 0x00007fff96ed0bb0 in -[NSManagedObjectContext processPendingChanges] ()
#1 0x00007fff96f26f78 in __90-[NSManagedObjectContext(_NSInternalNotificationHandling) _processEndOfEventNotification:]_block_invoke ()
#2 0x00007fff96ef67bf in -[NSManagedObjectContext(_NSInternalNotificationHandling) _processEndOfEventNotification:] ()
#3 0x00007fff949b8fcc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#4 0x00007fff948acc5d in _CFXNotificationPost ()
#5 0x00007fff907fc4aa in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#6 0x00007fff908895d3 in -[NSUndoManager _postCheckpointNotification] ()
#7 0x00007fff908893a8 in -[NSUndoManager _endUndoGroupRemovingIfEmpty:] ()
#8 0x00007fff9085c34d in +[NSUndoManager(NSPrivate) _endTopLevelGroupings] ()
#9 0x00007fff8e15da53 in -[NSApplication run] ()
#10 0x00007fff8e148803 in NSApplicationMain ()
#11 0x0000000100001992 in main
#12 0x0000000100001964 in start ()
#0 0x000000010000307f in -[RTDocument managedObjectContextDidChange:]
#1 0x00007fff949b8fcc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#2 0x00007fff948acc5d in _CFXNotificationPost ()
#3 0x00007fff907fc4aa in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#4 0x00007fff96f26ed8 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] ()
#5 0x00007fff96ed1306 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] ()
#6 0x00007fff96f26f78 in __90-[NSManagedObjectContext(_NSInternalNotificationHandling) _processEndOfEventNotification:]_block_invoke ()
#7 0x00007fff96ef67bf in -[NSManagedObjectContext(_NSInternalNotificationHandling) _processEndOfEventNotification:] ()
#8 0x00007fff949b8fcc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#9 0x00007fff948acc5d in _CFXNotificationPost ()
#10 0x00007fff907fc4aa in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#11 0x00007fff908895d3 in -[NSUndoManager _postCheckpointNotification] ()
#12 0x00007fff908893a8 in -[NSUndoManager _endUndoGroupRemovingIfEmpty:] ()
#13 0x00007fff9085c34d in +[NSUndoManager(NSPrivate) _endTopLevelGroupings] ()
#14 0x00007fff8e15da53 in -[NSApplication run] ()
#15 0x00007fff8e148803 in NSApplicationMain ()
#16 0x0000000100001992 in main
#17 0x0000000100001964 in start ()
However, If I call -processPendingChanges in my code, it triggers the notification, and the call stack looks like this, which seems weird, as -processPendingChanges isn’t actually on the stack. Am I reading this wrong?
#0 0x000000010000304f in -[RTDocument managedObjectContextDidChange:]
#1 0x00007fff949b8fcc in __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ ()
#2 0x00007fff948acc5d in _CFXNotificationPost ()
#3 0x00007fff907fc4aa in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#4 0x00007fff96f26ed8 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:withDeletions:withUpdates:withRefreshes:] ()
#5 0x00007fff96ed1306 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] ()
#6 0x000000010001249f in -[ReferencesController add:] <— calling -processPendingChanges here
Jim
_______________________________________________
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