objective-cioscore-datacopywithzone

NSmanagedObject copyWithZone issues


I have a custom class Thing:NSManagedObject with an attribute of adminName.

I am trying to create a copyWithZone function in this Thing class, but when I run the app it says setAdminName doesn't exist.

In my implementation file I am using

@dynamic adminName;


-(id) copyWithZone: (NSZone *) zone
{
Thing *regCopy = [[Thing allocWithZone: zone] init];
regCopy.attendeeNum = [self adminName];

return regCopy;
}

I don't believe I can just change @dynamic to @synthesize since I am using Core Data.


Solution

  • NSManagedObject does not conform to the NSCopying protocol. If you want to create a new record with the same data, just insert a new object and assign the values from the first object to the second object.