NSManagedObject subclass with additional properties not defined in model
Is it possible to define additional properties to a NSManagedObject subclass that are not defined within the Core Data Model? I have a series of additional properties that I do not want to include in the model.
I am able to save the NSMana开发者_StackOverflow中文版gedObject to the context just fine, but when I close the app then run a fetch after starting the app again, the NSManagedObject contains all null values...
Any ideas?
If you want to save those values you have to put them into your model, otherwise you are fine to create them each time the value is accessed and wasn't created earlier.
Lazy loading style.
- (NSString *)name {
if (!name) {
name = ...
}
return name;
}
精彩评论