Another Core Data Ivar Setter and Undo Issue
Another Core Data Ivar Setter and Undo Issue
- Subject: Another Core Data Ivar Setter and Undo Issue
- From: "Ian G. Gillespie" <email@hidden>
- Date: Tue, 26 Jun 2007 17:29:12 -0400
I've searched the archives and couldn't find and answer to my
question, so here goes...
I have Core Data app where one entity say, "Department", wants to
know when there is a change in one of its "Employee" entities
(typical one-to-many relationship example). In the past I registered
Department as an observer for changes in its Employees for the key
paths of interest. This worked fine accept that it led to some
performance issues when a Department was registering for changes in
say 5000-10,000 Employees. To address this I wanted to use my know
observing-notification system using NSNotificationCenter. I started
implementing custom accessors in my Employee managed object sub-class
so that I could post notifications (as seen below).
The problem is when I undo a change made on an Employee's property
the setMyValue: method is not called again. It is only called when
the user actually changes a value via bindings on the UI. I was
hoping that when Core Data invokes undo that it would call the
appropriate setter value for the property that changed. Is this the
expected behavior of Core Data?
-(void)setMyValue:(NSNumber *)sumValue {
[self willChangeValueForKey:@"myValue"];
[self setPrimitiveValue:sumValue forKey:@"myValue"];
[self didChangeValueForKey:@"myValue"];
//post the notification
[[NSNotificationCenter defaultCenter]
postNotificationName:@"myValueDidChange" object:self userInfo:nil];
}
_______________________________________________
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