• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Key-value coding dynamically-created arrays in NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Key-value coding dynamically-created arrays in NSTableView
      • From: Quincey Morris <email@hidden>
  • Prev by Date: A better solution? - Accessing an array of strings saved to user defaults via bindings (solved in the end...)
  • Next by Date: Re: model key path and properties
  • Previous by thread: A better solution? - Accessing an array of strings saved to user defaults via bindings (solved in the end...)
  • Next by thread: Re: Key-value coding dynamically-created arrays in NSTableView
  • Index(es):
    • Date
    • Thread