re: NSManagedObject Copy and Paste
re: NSManagedObject Copy and Paste
- Subject: re: NSManagedObject Copy and Paste
- From: Ben Trumbull <email@hidden>
- Date: Sun, 30 Mar 2008 17:03:26 -0700
I have a question regarding implementing copy and paste with
NSManagedObjects--
You're more or less on the right track. Here's an excerpt regarding
moving values between threads which may help you with copy&paste:
At 8:22 AM -0700 3/1/06, email@hidden wrote:
The problem with insertions is that the brand new objects are not
accessible to other contexts until they are saved. By accessible, I
mean semantically, as in their existence can't be communicated.
Until they are saved, the new objects don't have an identity (primary
key)
For updates and deletions, the objects have their permanent identity,
and you can use any of the standard Cocoa or OSX idioms for
communicating between threads to replicate those changes in a
different context.
Core Data doesn't have any additional routines for that.
However, Core Data offers the following on NSManagedObject:
- (NSDictionary *)committedValuesForKeys:(NSArray *)keys;
- (NSDictionary *)changedValues;
Also, NSManagedObject is fully KeyValueCoding compliant, and KVC has
a number of handy methods for pushing and pulling batches of changes:
-(NSDictionary *)dictionaryWithValuesForKeys:(NSArray *)keys
- (void)setValuesForKeysWithDictionary:(NSDictionary *)keyedValues
--
-Ben
_______________________________________________
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