Skip navigation.
 
mlBinding a popup button's selected index to a model integer
FROM : Johnny Lundy
DATE : Tue Apr 29 18:14:35 2008

Hello all,

I would appreciate some guidance in getting a popup button to use its 
selectedIndex to set an integer in my model.

I am having trouble understanding how to properly bind the selection 
of a popup to an integer in the model so that changes in the popup's 
selection changes the model integer's value.

My popup button's content is correctly set through its array 
controller to an array in my model.

I want to have the popup's set my model integer to the popup's 
selected item's index so that I may use the integer in my code to 
select the proper element in my model array. Thus I want changing the 
popup to KVC change the value of the integer model object gameType 
(NSInteger *, KVO compliant).

I have tried setting the popup's "selected index" binding to this 
NSNumber * model object.
I tried setting the popup's array controller's selectedIndex to the 
NSNumber * model object.
I tried making the model integer variable be a plain NSUInteger 
instead of an object.
None of these seem to activate the proper Cocoa Bindings mechanism.

I keep getting the usual

"2008-04-29 11:30:01.441 MafiaC9Arrays[29820:10b] Cocoa Bindings: 
Error accessing value for key path selectionIndex.gameType of object 
<NSArrayController: 0x1018870>[object class: NSString, number of 
selected objects: 0] (from bound object <NSPopUpButton: 0x1024090> 
with object ID 1475 in Nib named MainMenu.nib): [<NSCFNumber 
0x10551d0> valueForUndefinedKey:]: this class is not key value coding-
compliant for the key gameType."



I appreciate any guidance on this.

Johnny

Related mailsAuthorDate
mlBinding a popup button's selected index to a model integer Johnny Lundy Apr 29, 18:14
mlRe: Binding a popup button's selected index to a model integer I. Savant Apr 29, 18:25