![](../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../images/next.gif)
EOColumnAssociation
Inherits From:
EOAssociation : EODelayedObserver (EOControl) : NSObject
Conforms To:
NSCoding (EOAssociation)
EOObserving (EODelayedObserver)
NSObject (NSObject)
Declared in: EOInterface/EOColumnAssociation.h
Class Description
An EOColumnAssociation object cooperates with an EOTableViewAssociation to display values in a column of an NSTableView (Application Kit). A column association links an NSTableColumn (Application Kit) to a single attribute of all displayed objects in an EODisplayGroup. The value of each object is displayed in its corresponding row.
The EOTableViewAssociation receives target, delegate, and data source messages from the table view, and forwards them as needed to the appropriate column association. Column associations provide values for the cells of each NSTableColumn, and also accept edited values to set in their display groups.
EOColumnAssociations provide values using NSTableView's DataSource methods
tableView:setObjectValue:forTableColumn:row: and
tableView:objectValueForTableColumn: . This allows values with non-string representations to be displayed. For example, if an NSImageCell (Application Kit) is used as an NSTableColumn's data cell, an EOColumnAssociation can be used to display NSImages (Application Kit) in the NSTableView.
Usable With |
---|
NSTableColumn (Application Kit) |
Aspects | |
---|---|
value | An attribute of the objects, displayed in each row of the NSTableColumn. |
enabled | A boolean attribute of the objects, which determines whether each object's value cell is editable. Note that because EOTableViewAssociation also uses this aspect, you can use it with different keys to limit editability to the whole row or to an individual cell (column) in that row. |
Object Keys Taken | |
---|---|
identifier | An EOColumnAssociations sets itself as the identifer of its NSTableColumn. (Note: This key isn't formally
reserved by the objectKeysTaken method, as Interface Builder doesn't treat it as an outlet.)
|
Example
To display the last and first names of objects in a Talent display group, in Interface Builder, Control-drag a connection from the last name column to the display group. Select EOColumnAssociation in the Connections inspector, and bind the value
aspect to the "lastName" key (this automatically creates an EOTableViewAssociation to manage the individual columns). Repeat to set up a column association for the first name. Now when you run the application, the last and first names of each Talent object in the display group's displayedObjects
array are put in the correponding row.
- Sorting rows
- - setSortingSelector:
- - sortingSelector
- Table view data source methods
- - tableView:setObjectValue:forTableColumn:row:
- - tableViewObjectValueForLocationtableView: objectValueForTableColumn:row:
- Table view delegate methods
- - tableView:shouldEditTableColumn:row:
- - tableView:willDisplayCell:forTableColumn:row:
- Control delegate methods
- - controlDidFailToFormatStringErrorDescriptioncontrol:
didFailToFormatString:errorDescription:
- - control:isValidObject:
- - control:textShouldBeginEditing:
- - control:isValidObject:
Instance Methods
setSortingSelector:
- (void)setSortingSelector:
(SEL)aSelectorSets the method selector used to sort rows to aSelector, one of:
- EOCompareAscending
- EOCompareDescending
- EOCompareCaseInsensitiveAscending
- EOCompareCaseInsensitiveDescending
nil
(to tell the receiver not to sort)
compare...
methods in the Value Class Additions specification. If the EOTableViewAssociation for the receiver's NSTableView (Application Kit) sorts its rows, it applies this method as needed to sort them. The default sorting selector is EOCompareAscending.
sortingSelector
- (SEL)sortingSelector
Returns the method selector used to sort rows, or nil
if the column isn't sorted.
Data Source and Delegate Methods
These methods are forwarded by the corresponding NSTableView's EOTableViewAssociation to the appropriate EOColumnAssociation.
control:didFailToFormatString:errorDescription:
- (BOOL)control:
(NSControl *)aTableViewdidFailToFormatString:
(NSString *)aStringerrorDescription:
(NSString *)errorDescription
Invokes shouldEndEditingForAspect:invalidInput:errorDescription:
(defined by EOAssociation) and returns the result.
control:isValidObject:
- (BOOL)control:
(NSControl *)aTableViewisValidObject:
(id)anObject
Saves the value of any cell being edited using setValue:forAspect:
, and if successful sends an associationDidEndEditing:
message to the receiver's EODisplayGroup. Returns YES if successful (or if no changes need be saved), NO if unsuccessful.
control:textShouldBeginEditing:
- (BOOL)control:
(NSControl *)aTableViewtextShouldBeginEditing:
(NSText *)fieldEditor
Sends an associationDidBeginEditing:
message to the receiver's EODisplayGroup and returns YES.
tableView:objectValueForTableColumn:row:
- (id)tableView:
(NSTableView *)aTableViewobjectValueForTableColumn:
(NSTableColumn *)aTableColumnrow:
(int)rowIndex
Returns the value of the property of the object at rowIndex bound to the value
aspect.
tableView:setObjectValue:forTableColumn:row:
- (void)tableView:
(NSTableView *)aTableViewsetObjectValue:
(id)valueforTableColumn:
(NSTableColumn *)aTableColumnrow:
(int)rowIndex
Sets the property of the object at rowIndex bound to the value
aspect to value.
tableView:shouldEditTableColumn:row:
- (BOOL)tableView:
(NSTableView *)aTableViewshouldEditTableColumn:
(NSTableColumn *)aTableColumnrow:
(int)rowIndex
Returns NO if the enabled
aspect is bound and its value for the object at rowIndex is NO. Otherwise returns YES. Note that because the enabled
aspects of EOTableViewAssociation and EOColumnAssociation can be bound to different keys, you can limit editability to the whole row or to an individual cell (column) in that row.
tableView:willDisplayCell:forTableColumn:row:
- (void)tableView:
(NSTableView *)aTableViewwillDisplayCell:
(id)aCellforTableColumn:
(NSTableColumn *)aTableColumnrow:
(int)rowIndex
Alters the display characteristics for aCell according to the values for the enabled
aspect of the object at rowIndex.
![](../../../../../../../../../../images/previous.gif)
![](../../../../../../../../../../images/next.gif)
Copyright © 1998, Apple Computer, Inc. All rights reserved.