following the apple tutorial about core data (http://developer.apple.com/document...Paste.html#//apple_ref/doc/uid/TP40002833-SW6) i tried to naively extend this to copy the relationship by adding the key of the relationship to the keysToBeCopied array
the output window told me i have to implement an encodeWithCoder method
so i did.
it looked something a little like this:
it then complained saying it couldn't find the method setTitle.. so i changed title from dynamic to synthesize and made an instance variable
then it complained at me again saying i was making an illegal attempt to establish relationships between different contexts
any idea how this is done? This is a to-one relationship that i was trying to copy but i'll also want to copy for to-many relationships
should i just add the first object to the pasteboard and when it gets pasted just make copies of the objects it's related to? is that efficient?
the output window told me i have to implement an encodeWithCoder method
so i did.
it looked something a little like this:
Code:
- (void)encodeWithCoder:(NSCoder *)c {
[c encodeObject:self.title forKey:@"title"];
}
- (id) initWithCoder: (NSCoder *)c {
self = [super init];
if(self) {
self.title = [c decodeObjectForKey:@"title"];
}
return self;
}
then it complained at me again saying i was making an illegal attempt to establish relationships between different contexts
any idea how this is done? This is a to-one relationship that i was trying to copy but i'll also want to copy for to-many relationships
should i just add the first object to the pasteboard and when it gets pasted just make copies of the objects it's related to? is that efficient?