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
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 mails | Author | Date |
|---|---|---|
| Arthur C. | Jul 20, 18:13 | |
| Arthur C. | Jul 20, 18:14 | |
| Arthur C. | Jul 21, 11:21 | |
| George Orthwein | Jul 21, 16:29 | |
| Arthur C. | Jul 26, 22:51 |






Cocoa mail archive

