Theocacao
Leopard
Design Element
Comment on "Core Data: Forcing Propogation of Changes"
by Hannes Petri — Jun 04
A while ago, I tried to write a snippet-management-application, where you added pieces of text by dropping it on the dock icon. However, the text titles didn't show up in the table view, until I moved the window or something like that. A friend helped me solve it this way:

Put this in the init-method of the document:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(managedObjectContextUpdatedNotification:) name:NSManagedObjectContextObjectsDidChangeNotification object:[self managedObjectContext]];

And add the method like this:

-(void)managedObjectContextUpdatedNotification:(NSNotification *)notif
{
NSDictionary *userInfo = [notif userInfo];
NSSet *inserted = [userInfo objectForKey:NSInsertedObjectsKey];
if (yourArrayController && inserted && [inserted count]) {
[yourArrayController setSelectedObjects:[inserted allObjects]];
}
}
Back to "Core Data: Forcing Propogation of Changes"
Design Element

Copyright © Scott Stevenson 2004-2015