transient attributes of NSManagedObject reflected in isUpdated
transient attributes of NSManagedObject reflected in isUpdated
- Subject: transient attributes of NSManagedObject reflected in isUpdated
- From: Michael Link <email@hidden>
- Date: Tue, 29 Apr 2008 14:55:31 -0500
I noticed that if you have a transient attribute in an NSManagedObject
and update that attribute then isUpdated will return that the object
has unsaved changes. I suppose this makes some sense if the attribute
is actually defined in the entity. On the other hand if the managed
object has a subclass and a custom instance variable and a setter
method such as (using GC):
@property(assign) NSImage* iconImage;
- (void)setIconImage:(NSImage*)value
{
// isUpdated returns 0
[self willChangeValueForKey:@"iconImage"];
_iconImage = value;
[self didChangeValueForKey:@"iconImage"];
// isUpdated returns 1
}
The attribute isn't in the model and I don't really want Core Data to
know anything about it because it can't be saved in the store etc...
After this method is used isUpdated will return that the object has
unsaved changes, even though the attribute isn't part of the model and
changedValues is empty (since it's quite transient). My guess would be
that didChangeValueForKey: always sets a flag that marks the object as
being updated (even though none of the changes can be saved, and funny
enough when I quit the application is asks me if I want to save the
unsaved changes).
I'm trying to avoid having the object marked as updated because it
causes some issues with sorting being quite inaccurate for an
NSArrayController that uses lazy binding.
Is there anyway to set a custom instance variable in an
NSManagedObject subclass by still being key-value friendly and not
marking the object as updated?
--
Michael
_______________________________________________
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