On 19/07/2010, at 9:32 AM, Robb wrote:
> I'm trying to setup a table view with multiple columns, but I can't figure
> out how to identify any particular column.
> what does [tablecolumn identifier] actually return so i can compare it? I
> assumed a string, but that didn't work. So my questions is, what do I do
> with the NSTableColumn thats being passed to me?
Apart from the error that Quincey pointed out, matching table column
identifiers to a property of your data model doesn't require a bunch of
if..else..if..else statements. Use KVC, viz:
- (id) tableView:(NSTableView *) tv objectValueForTableColumn:(NSTableColumn *)
tc row:(NSInteger) index
{
id indexedObject = [[self arrayOfDataObjects] objectAtIndex:index];
return [indexedObject valueForKey:[tc indentifier]];
}
You sometimes need to do some extra work for a particular table column, but by
and large the above is nearly always all you need. Sometimes I think someone
has actually designed this stuff to make life easy ;-)
Looking at your code, you appear to have three separate arrays of the same
dimension holding individual properties. Instead, I would combine them into a
single array holding objects with three separate properties. Create a custom
NSObject subclass if needed. This will be far, far easier than trying to keep
three arrays in step, which is not a professional design.
--Graham_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]