Skip navigation.
 
mlCopying Core Data relationships
FROM : Matteo Manferdini
DATE : Fri Jul 07 19:22:32 2006

Hi, I have problems copyng core data relationships from an object to 
another.
I have an abstract entity in my model with a to-many relationship in 
it. Then I have two non-abstract entities that inherit from the 
abstract one, one of the two used to save copies of instances of the 
other entity. Let's say that object O is an instance of one of 
the"original" entity and object C is an instance of the "Copy" entity.
When I copy single attributes from O to C everything works fine, but 
when I copy the relationship, the references move from object O to 
object C, leaving O relationship empty.

The behaviour I want to achieve is to copy the references, not moving 
them. The problem arises if i use KVC as this:

[copy setValue:[original valueForKey:@"relationship"] 
forKey:@"relationship"]

but it arises even if I traverse the relationship of the original 
object with an enumerator and copy each item singularly, like this:

while (obj = [enumerator nextObject])
   [copyRelationship addObject:obj];

Why is this happening?
Thank you everyone.
Cheers.

---
Matteo Manferdini

Related mailsAuthorDate
mlCopying Core Data relationships Matteo Manferdini Jul 7, 19:22
mlRe: Copying Core Data relationships Matteo Manferdini Jul 7, 20:24