Core Data: rules for custom managed object setter implementations
Core Data: rules for custom managed object setter implementations
- Subject: Core Data: rules for custom managed object setter implementations
- From: "Sean McBride" <email@hidden>
- Date: Fri, 20 Nov 2009 11:32:10 -0500
- Organization: Rogue Research Inc.
Hi all,
If I implement a custom setter for an NSManagedObject attribute, what
can/can't I do?
For example, can I do nothing if the old and new values are the same?
- (void)setSalary:(NSNumber*)newsalary
{
get current salary
compare with newsalary
if different
[self willChangeValueForKey:@"salary"];
[self setPrimitiveValue:newsalary forKey:@"salary"];
[self didChangeValueForKey:@"salary"];
}
Or is it required to _always_ call willChange/setPrimitive/didChange?
Most of the time I use CD's dynamically generated accessors, but
occasionally I implement custom ones. I couldn't find a general
discussion of what can and can't be done safely in much methods.
Thanks,
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
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