EOGenericRecord
- Inherits from:
- NSObject
- Conforms to:
- NSCoding
- NSObject (NSObject)
Declared in:
- EOControl/EOGenericRecord.h
Class Description
EOGenericRecord is a generic enterprise object class that can be used in place of custom classes when you don't need custom behavior. It implements the EOEnterpriseObject interface to provide the basic enterprise object behavior. An EOGenericRecord object has an EOClassDescription that provides metadata about the generic record, including the name of the entity that the generic record represents and the names of the record's attributes and relationships. A generic record stores its properties in a dictionary using its attribute and relationship names as keys.
In the typical case of applications that access a relational database, the access layer's modeling objects are an important part of how generic records map to database rows: If an EOModel doesn't have a custom enterprise object class defined for a particular entity, an EODatabaseChannel using that model creates EOGenericRecords when fetching objects for that entity from the database server. During this process, the EODatabaseChannel also sets each generic record's class description to an EOEntityClassDescription, providing the link to the record's associated modeling objects. (EOModel, EODatabaseChannel, and EOEntityClassDescription are defined in EOAccess.)
Creating an Instance of EOGenericRecord
The best way to create an instance of EOGenericRecord is using the EOClassDescription method createInstanceWithEditingContext:globalID:zone: as follows:
id newEO; NSString *entityName; // Assume this exists. newEO = [[EOClassDescription classDescriptionForEntityName:entityName] createInstanceWithEditingContext:nil globalID:nil zone:nil];
createInstanceWithEditingContext:globalID:zone: is preferable to EOGenericRecord's init... method because the same code works if you later use a custom enterprise object class instead of EOGenericRecord. You can get an EOClassDescription for an entity name as shown above. Alternatively, you can get an EOClassDescription for a destination key of an existing enterprise object as follows:
id newEO; id existingEO; // Assume this exists. NSString *relationshipName; // Assume this exists. EOClassDescription *description = [existingEO classDescription]; newEO = [[description classDescriptionForDestinationKey:relationshipName] createInstanceWithEditingContext:editingContext lobalID:nil zone:nil];
The technique in this example is useful for inserting a new destination object into an existing enterprise object-for creating a new Movie object to add to a Studio's array of Movies, for example.
Class Methods
useDeferredFaultCreation
+ (BOOL)useDeferredFaultCreation
Instance Methods
init
- (id)init
initWithEditingContext:classDescription:globalID:
- (id)initWithEditingContext:(EOEditingContext
*)anEditingContext
classDescription:(EOClassDescription
*)aClassDescription
globalID:(EOGlobalID *)globalID
You shouldn't use this method to create new EOGenericRecords. Rather, use EOClassDescription's createInstanceWithEditingContext:globalID:zone: method. See the class description for more information.
storedValueForKey:
- (id)storedValueForKey:(NSString
*)key
See Also: storedValueForKey: ( EOKeyValueCoding)
takeStoredValue:forKey:
- (void)takeStoredValue:(id)value
forKey:(NSString *)key
See Also: takeStoredValue:forKey: ( EOKeyValueCoding)
takeValue:forKey:
- (void)takeValue:(id)value
forKey:(NSString *)key
valueForKey:
- (id)valueForKey:(NSString
*)key