Obviously, NSManagedObject does not comply with NSCoding . You could try to create an appropriate subclass of a subclass of the managed entity, but at best this would be an insidious proposition. NSManagedObject must have an associated NSManagedObjectID . And you cannot assign an identifier for an object - this happens automatically when you create an object. Even if your subclass was NSCoding , you would need to find a way to unlock the object, and also allow the local context of the managed object to assign an object identifier.
And even this ignores the question of how you will handle relationships in managed objects.
Converting to / from NSDictionary really much better. But you cannot just unlock the data and complete it. On the receiving side, you need to create a new instance of the managed entity and set its attribute values ββfrom the dictionary. You may be able to get your approach to work, but by the time you are done there will be more work and more code than if you were using NSDictionary .
Seriously: NSCoding , initWithCoder: copyWithZone: etc. - This is a really bad idea for the problem you are trying to solve. NSCoding is good for many situations, but it is not suitable here.
source share