Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > NSTableDataSource

NSTableDataSource
Thread Tools
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
Apr 1, 2004, 02:51 PM
 
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
Reply With Quote
Apr 1, 2004, 03:27 PM
 
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
Reply With Quote
Apr 1, 2004, 03:30 PM
 
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
Reply With Quote
Apr 1, 2004, 10:15 PM
 
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
Reply With Quote
Apr 7, 2004, 09:35 AM
 
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.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:06 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2