Managed Objects

Managed objects, or instances of NSManagedObject, are what an app will interact with the most. A managed object can be thought of as a dictionary with a known set of keys, and with known types of objects (like string or number) by key. Attributes for managed objects can always be accessed with this technique:

NSString *movieName = [myMovie valueForKey:@"movieName"];

And attributes can always be updated using setValue:forKey:

[myMovie setValue:@"Casablanca" forKey:@"movieName"];

Managed objects can be defined as subclasses of NSManagedObject, which will allow accessing the attributes as properties:

[myMovie setMovieName:@"Casablanca"];NSString ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.