 |
 |
NSTableDataSource
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
How do I determine which column to return data for in my tableView:objectValueForTableColumn:row: method? I have a simple table with 3 columns, and in my data source I can't determine which column I should return data for. I looked at the NSTableColumn class and it has an identifier, but unfortunately I can't figure out what to do with that. Any pointers? I would also like to establish the column headers in IB but I can't figure that out, either.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Nov 2002
Location: Seattle, WA
Status:
Offline
|
|
if you keep double-clicking on the header of the column you're interested in long enough (I think it's usually about 4 or 5 double-clicks), eventually you'll have selected the column instead of the tableview or the scrollview or whatever those are inside of. Then you set the title and identifier in the appropriate fields (you probably want to set them to the same thing to avoid confusion). Then in your data source method get the table column's identifier and it will be the same thing you set in IB. Alternatively you can get the tableColumn's header cell and getStringValue from that. I've always used the identifier though
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
Originally posted by Uncle Skeleton:
Then you set the title and identifier in the appropriate fields (you probably want to set them to the same thing to avoid confusion). Then in your data source method get the table column's identifier and it will be the same thing you set in IB. Alternatively you can get the tableColumn's header cell and getStringValue from that. I've always used the identifier though
OK, that's really good to know. So how to I compare the value of the identifier if I set it to, say, "Name"? Does the id object have a method to compare it to a String (I don't know ObjC much at all).
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Mar 2004
Status:
Offline
|
|
some skeletal sample code for this...
-(id) tableView: (NSTableView*) aTableView objectValueForTableColumn: (NSTableColumn*) aTableColumn row: (int) rowNum {
NSString* colIdentifier = (NSString*) [aTableColumn identifier];
// Keywords
if (aTableView == keywordsTableView) {
if ( [colIdentifier isEqualToString: @"Keyword"] ) {
return ...
}
}
else {
return @"ThisTableNotYetSupported";
}
}
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status:
Offline
|
|
Originally posted by alephnull:
some skeletal sample code for this...
-(id) tableView: (NSTableView*) aTableView objectValueForTableColumn: (NSTableColumn*) aTableColumn row: (int) rowNum {
NSString* colIdentifier = (NSString*) [aTableColumn identifier];
// Keywords
if (aTableView == keywordsTableView) {
if ( [colIdentifier isEqualToString: @"Keyword"] ) {
return ...
}
}
else {
return @"ThisTableNotYetSupported";
}
}
OK, that's good to know. I did something similar to that, but I noticed that I had some problems if the identifier had spaces in it.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |