Skip navigation.
 
mlHow to make KVO setup persistent?
FROM : Arthur C.
DATE : Fri Jul 21 11:21:29 2006

When I have two sets of objects, I can register for change notifications of
a property in the awakeFromInsert method, as follows:

- (void) awakeFromInsert
{
   static int localIndex = 0; // ignore the incorrect value at program restart
   NSManagedObjectContext * managedObjectContext = [[NSApp delegate]
ManagedObjectContext];
   [self setIndex: [NSNumber numberWithInt: localIndex]];

   Age * myAge = [NSEntityDescription insertNewObjectForEntityForName:
@"Age" inManagedObjectContext: managedObjectContext];
   [myAge setIndex: [NSNumber numberWithInt: localIndex++]];

   [self addObserver:myAge forKeyPath:@"yearofbirth"
options:NSKeyValueObservingOptionNew context:managedObjectContext];
}

This works OK when the program is first started (empty), but when it
is restarted the objects are reloaded with no KVO setup present.

What is the way to make the KVO setup persistent?
I have tried writing an applicationDidFinishLaunching method where
you can fetch all objects and setup KVO, but without success.


Best regards,

Arthur C.

_________________________________________________________________
Talk with your online friends with MSN Messenger
http://www.join.msn.com/messenger/overview

Related mailsAuthorDate
mlHow to make KVO setup persistent? Arthur C. Jul 20, 18:13
mlHow to make KVO setup persistent? Arthur C. Jul 20, 18:14
mlHow to make KVO setup persistent? Arthur C. Jul 21, 11:21
mlRe: How to make KVO setup persistent? George Orthwein Jul 21, 16:29
mlRe: How to make KVO setup persistent? Arthur C. Jul 26, 22:51