EOEnterpriseObject
(informal protocol)
Declared in:
- EOControl/EOClassDescription.h
- EOControl/EOEditingContext.h
- EOControl/EOKeyValueCoding.h
- EOControl/EOObserver.h
Protocol Description
The EOEnterpriseObject informal protocol identifies basic enterprise object behavior, defining methods for supporting operations common to all enterprise objects. Among these are methods for initializing instances, announcing changes, setting and retrieving property values, and performing validation of state. Some of these methods are for enterprise objects to implement or override, and some are meant to be used as defined by the Framework. Many methods are used internally by the Framework and rarely invoked by application code.
Many of the functional areas are defined in smaller, more specialized informal protocols and incorporated in the over arching EOEnterpriseObject informal protocol:
- EOKeyValueCoding defines Enterprise Objects Framework's main data transport mechanism, in which the properties of an object are accessed indirectly by name (or "key"), rather than directly through invocation of an accessor method or as instance variables.
- EOKeyBindingCreation defines a mechanism for binding class/key pairs with a method for accessing the key, which maximizes the performance of EOKeyValueCoding.
- EOKeyValueCodingAdditions defines extensions to the basic EOKeyValueCoding informal protocol, giving access to groups of properties and to properties across relationships.
- EORelationshipManipulation builds on the basic EOKeyValueCoding informal protocol to allow you to modify to-many relationship properties.
- EOValidation defines the way that enterprise objects validate their values.
The remaining methods are introduced in the EOEnterpriseObject informal protocol itself and can be broken down into three functional groups discussed in the following sections:
You rarely need to implement the EOEnterpriseObject informal protocol from scratch. The Framework provides default implementations of the methods in categories on NSObject. Use EOGenericRecords to represent enterprise objects that don't require custom behavior, and create subclasses of NSObject to represent enterprise objects that do. The section "Writing an Enterprise Object Class" highlights the methods that you typically provide or override in a custom enterprise object class.
Adopted Protocols
EOKeyValueCoding
- + accessInstanceVariablesDirectly
- + flushAllKeyBindings
- + useStoredAccessor
- - handleQueryWithUnboundKey:
- - handleTakeValue:forUnboundKey:
- - storedValueForKey:
- - takeStoredValue:forKey:
- - takeValue:forKey:
- - unableToSetNullForKey:
- - valueForKey:
EOKeyValueCodingAdditions
- - takeValue:forKeyPath:
- - takeValuesFromDictionary:
- - valueForKeyPath:
- - valuesForKeys:
EORelationshipManipulation
- - addObject:toBothSidesOfRelationshipWithKey:
- - addObject:toPropertyWithKey:
- - removeObject:fromBothSidesOfRelationshipWithKey:
- - removeObject:fromPropertyWithKey:
EOValidation
- - validateForDelete
- - validateForInsert
- - validateForSave
- - validateForUpdate
- - validateValue:forKey:
Method Types
- Initializing enterprise objects
- - initWithEditingContext:classDescription:globalID:
- - awakeFromFetchInEditingContext:
- - awakeFromInsertionInEditingContext:
- Announcing changes
- - willChange
- Getting an object's EOEditingContext
- - editingContext
- Getting class description information
- - allPropertyKeys
- - attributeKeys
- - classDescription
- - classDescriptionForDestinationKey:
- - deleteRuleForRelationshipKey:
- - entityName
- - inverseForRelationshipKey:
- - isToManyKey:
- - ownsDestinationObjectsForRelationshipKey:
- - toManyRelationshipKeys
- - toOneRelationshipKeys
- Modifying relationships
- - propagateDeleteWithEditingContext:
- - clearProperties
- Working with snapshots
- - snapshot
- - updateFromSnapshot:
- Merging values
- - changesFromSnapshot
- - reapplyChangesFromDictionary:
- Getting descriptions
- - eoDescription
- - eoShallowDescription
- - userPresentableDescription
Instance Methods
allPropertyKeys
- (NSArray *)allPropertyKeys
attributeKeys
- (NSArray *)attributeKeys
See Also: - toOneRelationshipKeys, - toManyRelationshipKeys
awakeFromFetchInEditingContext:
- (void)awakeFromFetchInEditingContext:(EOEditingContext
*)anEditingContext
awakeFromInsertionInEditingContext:
- (void)awakeFromInsertionInEditingContext:(EOEditingContext
*)anEditingContext
changesFromSnapshot
- (NSDictionary *)changesFromSnapshot:(NSDictionary
*)snapshot
Returns a dictionary whose keys correspond to the receiver's properties with uncommitted changes relative to snapshot, and whose values are the uncommitted values. In both snapshot and the returned dictionary, where a key represents a to-many relationship, the corresponding value is an NSArray containing two other NSArrays: the first is an array of objects to be added to the relationship property, and the second is an array of objects to be removed.
See Also: - reapplyChangesFromDictionary:
classDescription
- (EOClassDescription *)classDescription
classDescriptionForDestinationKey:
- (EOClassDescription *)classDescriptionForDestinationKey:(NSString
*)key
clearProperties
- (void)clearProperties
deleteRuleForRelationshipKey:
- (EODeleteRule)deleteRuleForRelationshipKey:(NSString
*)relationshipKey
For example, an Invoice object might return EODeleteRuleNullify
for
the relationship named "lineItems", since when an invoice is
deleted, its line items should be deleted as well. For more information
on the delete rules, see the method description for EOClassDescription's deleteRuleForRelationshipKey: in
the class specification for EOClassDescription.
NSObject's implementation of this method simply sends a deleteRuleForRelationshipKey: message to the receiver's EOClassDescription.
See Also: - propagateDeleteWithEditingContext:, - validateForDelete (EOValidation)
editingContext
- (EOEditingContext *)editingContext
entityName
- (NSString *)entityName
eoDescription
- (NSString *)eoDescription
This method is useful for debugging. You can implement a description method that invokes this one, and the debugger's print-object command (po on the command line) automatically displays this description. You can also invoke this method directly on the command line of the debugger.
See Also: - userPresentableDescription
eoShallowDescription
- (NSString *)eoShallowDescription
id
.
See Also: - userPresentableDescription
initWithEditingContext:classDescription:globalID:
- initWithEditingContext:(EOEditingContext
*)anEditingContext classDescription:(EOClassDescription
*)aClassDescription
globalID:(EOGlobalID *)globalID
See Also: - createInstanceWithEditingContext:globalID:zone: (EOClassDescription)
inverseForRelationshipKey:
- (NSString *)inverseForRelationshipKey:(NSString
*)relationshipKey
You might override this method for reciprocal relationships that aren't defined using the same join attributes. For example, if a Member object has a relationship to CreditCard based on the card number, but a CreditCard has a relationship to Member based on the Member's primary key, both classes need to override this method. This is how Member might implement it:
- (NSString *)inverseForRelationshipKey:(NSString *)relationshipKey { if ([relationshipKey isEqual:@"creditCard"]) return @"member"; return [super inverseForRelationshipKey:relationshipKey]; }
isToManyKey:
- (BOOL)isToManyKey:(NSString
*)key
ownsDestinationObjectsForRelationshipKey:
- (BOOL)ownsDestinationObjectsForRelationshipKey:(NSString
*)key
See Also: - deleteRuleForRelationshipKey:, - ownsDestination (EOAccess' EORelationship)
propagateDeleteWithEditingContext:
- (void)propagateDeleteWithEditingContext:(EOEditingContext
*)anEditingContext
See Also: - deleteRuleForRelationshipKey:
reapplyChangesFromDictionary:
- (void)reapplyChangesFromDictionary:(NSDictionary
*)changes
Similar to takeValuesFromDictionary:, but the changes dictionary can contain arrays for to-many relationships. Where a key represents a to-many relationship, the dictionary's value is an NSArray containing two other NSArrays: the first is an array of objects to be added to the relationship property, and the second is an array of objects to be removed. NSObject's implementation should be sufficient for all purposes; you shouldn't have to override this method.
See Also: - changesFromSnapshot
snapshot
- (NSDictionary *)snapshot
See Also: - updateFromSnapshot:
toManyRelationshipKeys
- (NSArray *)toManyRelationshipKeys
See Also: - attributeKeys, - toOneRelationshipKeys
toOneRelationshipKeys
- (NSArray *)toOneRelationshipKeys
See Also: - attributeKeys, - toManyRelationshipKeys
updateFromSnapshot:
- (void)updateFromSnapshot:(NSDictionary
*)aSnapshot
See Also: - snapshot
userPresentableDescription
- (NSString *)userPresentableDescription
Returns a short (no longer than 60 characters) description of an enterprise object based on its data. NSObject's implementation enumerates the object's attributeKeys and returns the values of all of its properties, separated by commas (applying the default formatter for numbers and dates).
See Also: - eoDescription, - eoShallowDescription
willChange
- (void)willChange
- (void)setRoleName:(NSString *)value { [self willChange]; [roleName autorelease]; roleName = [value retain]; }