Key-value coding dynamically-created arrays in NSTableView
Key-value coding dynamically-created arrays in NSTableView
- Subject: Key-value coding dynamically-created arrays in NSTableView
- From: John Bartleson <email@hidden>
- Date: Thu, 14 Jul 2011 17:08:31 -0700
Many of us are familiar with the use of key-value coding in
NSTableView and NSOutlineView data-source methods.
For example (from Key-Value Coding Programming Guide):
- (id) tableView:(NSTableView *)tableview
objectValueForTableColumn:(id)column
row:(int)row
{
ChildObject *child = [childrenArray objectAtIndex:row];
return [child valueForKey:[column identifier]];
}
Here the column identifier specified in the nib is used to select
which ChildObject accessor
to use as the source for the column's data.
But suppose the columns of the tableView are not defined in the nib.
Instead, they are defined
dynamically by user action at run time. It's easy to dynamically add
columns to the tableView and to
give each one a unique identifier , but is it even possible to somehow
assign key names to elements
in a dynamic data array so valueForKey: can find those elements?
This issue is made more difficult because the technique valueForKey
uses to select an accessor is not
apparent, at least to a n00b like me. For extra points, can anyone
describe how valueForKey works?
(I'm not using bindings)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden