![](../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../images/next.gif)
EOAssociation
Inherits From:
EODelayedObserver (EOControl) : NSObject
Conforms To:
NSCoding
EOObserving (EODelayedObserver)
NSObject (NSObject)
Declared in: EOInterface/EOAssociation.h
Class At a Glance:
Purpose
Principal Attributes
- A display object (such as a text field or combo box)
- Aspects that control different parameters of the display object (such as
value
andenabled
) - One or more EODisplayGroups (no more than one per aspect)
- One or more keys (enteprise object properties) (as many as one key per aspect)
Creation
- Interface Builder
- - initWithObject: Designated initializer.
Class Description
EOAssociation defines the mechanism that transfers values between EODisplayGroups and the user interface of an application. An EOAssociation instance is tied to a single display object, a user interface object or other kind of object that manages values intended for display. The EOAssociation takes over certain outlets of the display object and sets its value according to the selection in the EODisplayGroup. An EOAssociation also has various aspects, which define the different parameters of the display object that it controls, such as the value or values displayed and whether the display object is enabled or editable. Each aspect can be bound to an EODisplayGroup with a key denoting a property of the enterprise objects in the EODisplayGroup. The value or values of this property determine the value for the EOAssociation's aspect.
EOAssociation is an abstract class, defining only the general mechanism for binding display objects to EODisplayGroups. You always create instances of its various subclasses, which define behavior specific to different kinds of display objects. See the listing in the Class at a Glance section for standard EOAssociation subclasses.
You normally set up EOAssociations using Interface Builder; each of the class specifications for EOAssociation's subclasses provide an example using Interface Builder to set them up. EOAssociation's programmatic interface is more important when defining custom EOAssociation subclasses. For more information on EOAssociations, see the sections:
- How EOAssociations Work
- Setting up an EOAssociation Programmatically
- Creating a Subclass of EOAssociation
Adopted Protocols
- NSCoding - encodeWithCoder:
- - initWithCoder:
Method Types
- Declaring capabilities
- + aspects
- + aspectSignatures
- + objectKeysTaken+ isUsableWithObject:
- + associationClassesSuperseded+ displayName
- + primaryAspect
- - canBindAspect:displayGroup:key:
- + aspectSignatures
- Getting all possible EOAssociations for a display object
- + associationClassesForObject:
- Creating and configuring instances
- - initWithObject:
- - bindAspect:displayGroup:key:
- - establishConnection
- - breakConnection
- - copyMatchingBindingsFromAssociation:
- - bindAspect:displayGroup:key:
- Getting the display object
- - object
- Examining bindings
- - displayGroupForAspect:
- - displayGroupKeyForAspect:
- Updating values
- - subjectChanged
- - endEditing
- Accessing enterprise object values
- - setValue:forAspect:
- - setValue:forAspect:atIndex:
- - valueForAspect:
- - valueForAspect:atIndex:
- - setValue:forAspect:atIndex:
- Handling validation errors
- - shouldEndEditingForAspect:invalidInput:errorDescription:
- - shouldEndEditingForAspect:invalidInput:errorDescription:index:
Class Methods
aspects
+ (NSArray *)aspects
Overridden by subclasses to return the names of the receiving class's aspects as an array of string objects. Subclasses should include their superclass's aspects and add their own when overriding this method.
aspectSignatures
+ (NSArray *)aspectSignatures
Overridden by subclasses to return the signatures of the receiver's aspects, an array of string objects matching its aspects array index for index. Each signature string can contain the following characters:
Signature Character | Meaning |
---|---|
A | The aspect can be bound to attributes. |
1 (one) | The aspect can be bound to to-one relationships. |
M | The aspect can be bound to to-many relationships. |
An aspect signature string of "A1", for example, means the corresponding aspect can be bound to either attributes or to-one relationships. An empty signature indicates that the corresponding aspect can be bound to an EODisplayGroup without a key (that is, the key is irrelevant). Interface Builder uses aspect signatures to enable and disable keys in its Connections inspectors.
EOAssociation's implementation of this method returns an array of "A1M" of the length of its aspects array.
associationClassesForObject:
+ (NSArray *)associationClassesForObject:
(id)aDisplayObject
Returns the subclasses of EOAssociation usable with aDisplayObject. Sends isUsableWithObject:
to every loaded subclass of EOAssociation, adding those that respond YES to the array. Subclasses shouldn't override this method; override
isUsableWithObject:
instead.
associationClassesSuperseded
+ (NSArray *)associationClassesSuperseded
Overridden by subclasses to return the other EOAssociation classes that the receiver supplants. This allows a subclass to mask its superclasses from the Connection Inspector's pop-up list in Interface Builder, since the subclass always includes the aspects and functionality of its superclasses. For example, EOPopUpAssociation supersedes EOControlAssociation, because for pop-up buttons an EOPopUpAssociation is always more appropriate to use.
displayName
+ (NSString *)displayName
Returns the name used by Interface Builder in the Connection Inspector's pop-up list. EOAssociation's implementation simply returns the name of the receiving class.
isUsableWithObject:
+ (BOOL)isUsableWithObject:
(id)aDisplayObject
Overridden by subclasses to return YES if instances of the receiving class are usable with aDisplayObject,
NO if they aren't. The receiving class can examine any relevant characteristic of aDisplayObject-its class, configuration (such as whether an NSMatrix operates in radio mode), and so on.
objectKeysTaken
+ (NSArray *)objectKeysTaken
Overridden by subclasses to return the names of display object outlets that instances assume control of, such as "target" and "delegate". Interface Builder uses this information to disable connections from these outlets in its Connections Inspector.
primaryAspect
+ (NSString *)primaryAspect
Overridden by subclasses to return the default aspect, usually one denoting the displayed value, which by convention is named "value". EOAssociation's implementation returns nil
.
Instance Methods
bindAspect:displayGroup:key:
- (void)bindAspect:
(NSString *)aspectNamedisplayGroup:
(EODisplayGroup *)aDisplayGroupkey:
(NSString *)key
Defines the receiver's link between its display object and aDisplayGroup. aspectName is the name of the aspect it observer in its display object, and key is the name of the property it observes in aDisplayGroup. Invoke establishConnection
after this method to finish setting up the binding. See "Setting up an EOAssociation Programmatically" in the class description for more information.
See also:
- initWithObject:
, - establishConnection
breakConnection
- (void)breakConnection
Removes the receiver from its EODisplayGroup and display object. This causes it to be released, so be sure to retain the EOAssociation before invoking this method if you want to keep it for another use. Subclasses should override this method to remove the receiver from any outlets of the display object, such as target or delegate, and invoke super
's implementation at the end.
See also:
- establishConnection
canBindAspect:displayGroup:key:
- (BOOL)canBindAspect:
(NSString *)aspectNamedisplayGroup:
(EODisplayGroup *)aDisplayGroupkey:
(NSString *)key
Overridden by subclasses to return YES if the receiver can tie an aspect named aspectName from its display object to the property identified by key in aDisplayGroup,
NO if it can't. aspectName should name an aspect supported by the receiver's class.
Interface Builder uses this information to disable aspects in its Connections Inspector. Subclasses can override this method to base their answers on other binds already made, or on characteristics of the receiver's display object or of aDisplayGroup. EOAssociation's implementation always returns YES.
See also:
- localKeys
(EODisplayGroup), - attributeKeys (EOClassDescription),
- toOneRelationshipKeys
(EOClassDescription),
- toManyRelationshipKeys
(EOClassDescription)
copyMatchingBindingsFromAssociation:
- (void)copyMatchingBindingsFromAssociation:
(EOAssociation *)anAssociation
Duplicates the bindings of anAssociation in the receiver. For each aspect of anAssociation that has an EODisplayGroup, invokes bindAspect:displayGroup:key:
with the EODisplayGroup and key for that aspect.
displayGroupForAspect:
- (EODisplayGroup *)displayGroupForAspect:
(NSString *)aspectName
Returns the EODisplayGroup bound to the receiver for aspectName, or nil
if there's no such object.
See also:
- displayGroupKeyForAspect:
displayGroupKeyForAspect:
- (NSString *)displayGroupKeyForAspect:
(NSString *)aspectName
Returns the EODisplayGroup key bound to the receiver for aspectName, or nil
if there's no EODisplayGroup.
See also:
- displayGroupForAspect:
endEditing
- (BOOL)endEditing
Overridden by subclasses to pass the value of the receiver's display object to the EODisplayGroup, by invoking setValue:forAspect:
with the display object's value and the appropriate aspect (typically "value"). Returns YES if successful,
NO if not-specifically if
setValue:forAspect:
returns NO. The receiver should also send an
associationDidEndEditing:
message to its EODisplayGroup.
Subclasses whose display objects immediately pass their changes back to the EOAssociation-such as a button or pop-up list-need not override this method. It's only needed when the display object's value is edited rather than simply set.
EOAssociation's implementation does nothing but return YES.
establishConnection
- (void)establishConnection
Overridden by subclasses to attach the receiver to the outlets of its display object, and to otherwise configure the display object (such as by setting its
action method). EOAssociation's implementation subscribes the receiver as an observer of its EODisplayGroups and causes the display object to retain the receiver. Subclasses should invoke
super
's implementation after establishing their own connections.See "Setting up an EOAssociation Programmatically" in the class description for more information.
See also:
- breakConnection
initWithObject:
- (id)initWithObject:
(id)aDisplayObject
Initializes the receiver to monitor and update the value in aDisplayObject, which is typically a user-interface object or an EODisplayGroup. This is the designated initializer for the EOAssociation class. Returns self
.
Note: Because of the way that EOAssociations are set up, this method doesn't retain aDisplayObject. See "Setting up an EOAssociation Programmatically" in the class description for more information.
See also:
- bindAspect:displayGroup:key:
, - establishConnection
Returns the receiver's display object.
See also:
- initWithObject:
setValue:forAspect:
- (BOOL)setValue:
(id)valueforAspect:
(NSString *)aspectName
Sets a value of the selected enterprise object in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a setSelectedObjectValue:forKey:
message with value and the key as arguments. Returns YES if successful, or if there's no display group bound to aspectName. Returns
NO if there's an display group and it doesn't accept the new value.
See also:
- valueForAspect:
setValue:forAspect:atIndex:
- (BOOL)setValue:
(id)valueforAspect:
(NSString *)aspectNameatIndex:
(unsigned int)index
Sets a value of the enterprise object at index in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a setValue:forObjectAtIndex:key:
message with value, index, and the key as arguments. Returns YES if successful, or if there's no display group bound to aspectName. Returns
NO if there's a display group and it doesn't accept the new value.
See also:
- valueForAspect:atIndex:
shouldEndEditingForAspect:invalidInput:errorDescription:
- (BOOL)shouldEndEditingForAspect:
(NSString *)aspectNameinvalidInput:
(NSString *)inputStringerrorDescription:
(NSString *)errorDescription
Invoked by subclasses when the display object fails to validate its input, this method informs the EODisplayGroup bound to aspectName with an association:failedToValidateValue:forKey:object:errorDescription:
message, using the display group's selected object. Returns the result of that message, or YES if there's no display group.
For example, an association bound to an NSControl object (Application Kit) receives a
control:didFailToFormatString:errorDescription: delegate message when the control's formatter fails to format the input string. Its implementation of that method invokes
shouldEndEditingForAspect:invalidInput:errorDescription:
.
See also:
- shouldEndEditingForAspect:invalidInput:errorDescription:index:
shouldEndEditingForAspect:invalidInput:errorDescription:index:
- (BOOL)shouldEndEditingForAspect:
(NSString *)aspectNameinvalidInput:
(NSString *)inputStringerrorDescription:
(NSString *)errorDescriptionindex:
(unsigned int)index
Works in the same manner as shouldEndEditingForAspect:invalidInput:errorDescription:
, but allows you to specify a particular object by index rather than implicitly specifying the selected object.
subjectChanged
- (void)subjectChanged
Overridden by subclasses to update state based when an EODisplayGroup's selection or contents changes. This method is invoked automatically anytime a display group that's bound to the receiver changes. The receiver can query its display group with selectionChanged
and contentsChanged
messages to determine how it needs to update.
valueForAspect:
- (id)valueForAspect:
(NSString *)aspectName
Returns a value of the selected enterprise object in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a selectedObjectValueForKey:
message with the key. Returns nil
if there's no display group or key bound to aspectName.
See also:
- setValue:forAspect:
valueForAspect:atIndex:
- (id)valueForAspect:
(NSString *)aspectNameatIndex:
(unsigned int)index
Returns a value of the enterprise object at index in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a valueForObjectAtIndex:key:
message with index and the key. Returns nil
if there's no display group or key bound to aspectName.
See also:
- setValue:forAspect:atIndex:
![](../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../images/next.gif)
Copyright © 1998, Apple Computer, Inc. All rights reserved.