NSPopUpButton/NSArrayController selected item for beyond bounds value?
NSPopUpButton/NSArrayController selected item for beyond bounds value?
- Subject: NSPopUpButton/NSArrayController selected item for beyond bounds value?
- From: Keith Blount <email@hidden>
- Date: Tue, 4 Mar 2008 09:43:54 -0800 (PST)
Hi,
Hopefully this is a simple one:
I have an NSTableView, one column of which uses NSPopUpButtonCell and has its content bound to one NSArrayController which controls an array of list item strings for selection. Its selectedIndex is bound to the property of a different array controller. The actual index that gets loaded in may be beyond the number of items in the list array (as it may previously have been associated with a different list). In this case, the table view just shows an empty cell.
This is okay, but what I'd really like is to set a default selection index in this case. i.e. If the selectedIndex of the object >= [popupListArray count], then set it to select the last (or first) item (i.e. so that internally it is doing something like, if (selectedIndex >= [popupListArray count]) { selectedIndex = [popupListArray count]-1; } ). I thought I might be able to do this automatically using the "No selection" or "Not applicable" placeholder, but it turns out that it doesn't quite work like that. Is there a way of setting this up automatically, or near-to-automatically?
Many thanks in advance,
Keith
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden