Reputation: 556
I have an object which inherits from NSObject & I wish to save it in CoreData, I have already create an attribute of type "Transformable" (which is "id"), so I cannot save the project directly when adding it to the database, for example:
item.idObject = object;
it will generate an error, I think the problem is that I should transform object into id, how can I do this?
Upvotes: 1
Views: 118
Reputation: 150615
You're on the right track by setting the attribute to transformable. But what you also have to to is to write a valueTransformer for this object that Core Data can use.
There is more in the Documentation
Upvotes: 2
Reputation: 14549
when you assign a core data property, it may only be of certain types, NSString, NSNumber etc... if you assign a relationship, it must be another NSManagedObject instance, if you want to save it as part of the model, you can of course have transient properties of any type.
so...
@implimentation OurClass
@dynamic someProperty; // core data model property NSNumber, NSString, etc.
@dynamic someRelationship; // core data relationship some other subclass of NSManagedObject
@synthesized someOtherProperty; // can be anything, following normal Objective-C semantics.
@end
Upvotes: 0