Re: Copy managed object between contexts?
Re: Copy managed object between contexts?
- Subject: Re: Copy managed object between contexts?
- From: Jim Correia <email@hidden>
- Date: Sat, 13 Aug 2005 20:40:03 -0400
On Aug 13, 2005, at 8:27 PM, Colin Cornaby wrote:
So in other words, Apple recommends doing it manually. :)
But you can write generic code once, and then use it over and over
again. So it is only manual the first time :-)
@interface NSManagedObject(CopyAdditions)
- (void)copyAttributesFromObject:(NSManagedObject *)object
{
NSArray *attributeKeys = [[self entity] attributeKeys];
NSEnumerator *enumerator = [attributeKeys objectEnumerator];
NSString *attributeName = nil;
while (nil != (attributeName = [enumerator nextObject]))
{
[self setValue: [object valueForKey: attributeName] forKey:
attributeName];
}
}
@end
It is left as an exercise to the reader to do the same for
relationships.
Jim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden