Core Data

ctrl-drag to create relationship between entities.

key-value coding is implemented in cocoa's foundation framework as an "informal protocol". An informal protocol is a category, that adds methods to the NSObject base class so that all objects can be safely assumed to implement the methods and is principally implemented by the methods added to NSObject.

 

-(id)valueForKey:(NSString *) akey
-(id)setValue:(id)aValue forKey:(NSString *)aKey

Finally, if the receiver can’t supply a value for the specified key,-valueForKey:calls the Key Value Coding method -valueForUndefinedKey:(NSString *)aKey, and NSObject’s implementation of -valueForUndefinedKey:just raises an NSUndefinedKeyException.

 

TheNSManagedObjectclass overrides the NSObjectimplementation of -valueForKey: to consult with an NSEntityDescriptionand check whether the requested key corresponds to a property of the entity being represented. If so,NSManagedObjectdoes what-ever is necessary to obtain the corresponding property’s value and return it. Similarly, NSManagedObjectchecks whether properties being set exist within the represented entity.

posted on 2012-04-22 20:41  grep  阅读(152)  评论(0编辑  收藏  举报