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 > displaying bool in nstableview

displaying bool in nstableview
Thread Tools
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Nov 5, 2001, 06:21 PM
 
hi everybody,

does anybody have an idea how to make nstableview display bools as checkboxes? looked at formatters, but they are only good for strings.

in java, this is so easy...

anybody?
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Nov 5, 2001, 08:29 PM
 
Just set the dataCell for that table column to be a properly configured NSButtonCell.

From some old code I have...

NSButtonCell *dataCell;
NSTableColumn *column; //assume this exists

dataCell = [[[NSButtonCell alloc] init] autorelease];
[dataCell setButtonType:NSSwitchButton];
[dataCell setTitle:@""];
[dataCell setAlternateTitle:@""];
[dataCell setBordered:NO]; //does this make a difference?
[dataCell setImagePosition:NSImageOnly];
[dataCell setEditable:[column isEditable]];
[column setEditable:NO]; //gets in the way...
[column setDataCell:dataCell];
     
seb2  (op)
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Nov 6, 2001, 01:05 AM
 
this works. great! but... what do i return in
- (id)tableView :objectValueForTableColumn:row:?

sorry, i'm used to java and tried returning YES or NO and this just crashes it...

[edit: haha, that smily in there is so appropriate that i left smilies enabled...]

[ 11-06-2001: Message edited by: seb2 ]
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
Nov 6, 2001, 03:41 AM
 
Well, you need to return an object :-) YES and NO are scalar values.

return [NSNumber numberWithBool:YES];
     
seb2  (op)
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
Nov 6, 2001, 03:56 PM
 
well, i guess i could have thought of that myself... ;-)

it works, thank you so much!
     
   
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:59 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