A subclass of NSManagedObject with additional properties not defined in the model

Can I define additional properties for a subclass of NSManagedObject that are not defined in the Core Data Model? I have a number of additional properties that I do not want to include in the model.

I can easily save NSManagedObject in context, but when I close the application, then run the selection after the application starts, NSManagedObject contains all the null values ​​...

Any ideas?

+3
source share
1 answer

If you want to save these values, you must put them in your model, otherwise you can create them every time the value is available and has not been created before.

Lazy loading style.

- (NSString *)name {
    if (!name) {
        name = ...
    }
    return name;
}
+2
source

All Articles