How to make KVO setup persistent?
How to make KVO setup persistent?
- Subject: How to make KVO setup persistent?
- From: "Arthur C." <email@hidden>
- Date: Fri, 21 Jul 2006 11:21:29 +0200
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
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden