RE: [Q] am I allowed to call NSTableDataSource informal protocol methods myself?
RE: [Q] am I allowed to call NSTableDataSource informal protocol methods myself?
- Subject: RE: [Q] am I allowed to call NSTableDataSource informal protocol methods myself?
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Tue, 27 Apr 2004 17:09:41 -0400
>
Because at present to get the contents of the cell I now do the
>
following:
>
.....
>
// Get the text in the MAC Address cell and validate it
>
unsigned int row = [tableView selectedRow];
>
PasswordRecord *pwrec = [passwordRecords objectAtIndex:row];
>
tempDelimitedString =[pwrec macAddress]; // using the accessor
>
,,,,,,,
>
and it occurred to me that it would be more elegant to use
>
objectValueForTableColumn along the lines of:
>
>
tempDelimitedString = [tableView objectValueForTableColumn:[tableView
>
tableColumnWithIdentifier:@"macAddress"]:[tableView selectedRow]
I think the elegance of using the data source method is quite debateable.
Most cocoa programmers would probably tell you to interact with the data
model directly, rather than going indirectly through the data source, at
least in the ordinary case. If you simply want to eliminate a few
variables, you can do:
tempDelimitedString = [(PasswordRecord *)[passwordRecords
objectAtIndex:[tableView selectedRow]] macAddress];
But if you are hell-bent for using the datasource, you could do:
tempDelimitedString = [[tableView datasource]
objectValueForTableColumn:[tableView
tableColumnWithIdentifier:@"macAddress"] row:[tableView selectedRow]];
That is, you want to send the message to the datasource, not the tableview
itself.
Jonathan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.