开发者

Is there an difference between transient properties defined in the data model, or in the custom subclass of NSManagedObject?

开发者 https://www.devze.com 2023-01-03 04:35 出处:网络
I was reading that setting the value of a transient property always results in marking the managed object as \"dirty\". However, what I don\'t get is this: If I make a subclass of NSManagedObject and

I was reading that setting the value of a transient property always results in marking the managed object as "dirty". However, what I don't get is this: If I make a subclass of NSManagedObject and use some extra properties which I don't need to be persistet, how does Core Data know about them and how can it mark the object as dirty when I access these?

Again, they're not defined in the data model, so Core Data has no really good hint that they are there.

Or does Core Data use some kind of introspection to analyze my custom class and figure out what properties I have in t开发者_Python百科here?


NSManagedObject
/*  Distinguish between changes that should and should not dirty the object for any key unknown to Core Data.  10.5 & earlier default to NO.  10.6 and later default to YES. */
/*    Similarly, transient attributes may be individually flagged as not dirtying the object by adding +(BOOL)contextShouldIgnoreChangesFor<key> where <key> is the property name. */
+ (BOOL)contextShouldIgnoreUnmodeledPropertyChanges NS_AVAILABLE(10_6,3_0);

transient attributes can be handled by Undo/Redo manager, extra properties not.

I've found some strange behaviour of core data "dirty" making rule:

on iOS 5 setting transient property in -(void)didSave make context dirty but on iOS 4.3 makes not.

how to make NSManagedObjectContext dirty (hasChanges = YES) Manually

I don't think that core data may introspect you custom subclasses of NSManagedObjects

0

精彩评论

暂无评论...
验证码 换一张
取 消