Hi All,

I have an NSComboBox that is bound to a datasource.  I want to programatically 
select a default selection when the sheet the combobox is in is first 
displayed.  To do so I am doing the following:

NSString * defaultSelectionValue = [myDS defaultSelectionValue];

NSUInteger defaultSelectionIndex =  [myDS comboBox:self 
indexOfItemWithStringValue:defaultSelectionValue];

[self selectItemAtIndex:defaultSelectionIndex];
                
[self setObjectValue:[myDS comboBox:self 
objectValueForItemAtIndex:defaultSelectionIndex]];

'self' is a subclass of NSCombobox.  'myDS' is the datasource - which contains 
has information of what the default selection should be (stored in an NSString).

In interface builder I bound the value of the NSComboBox to a variable in a 
model class.

My problem is that it seems the model variable is not being properly informed 
of the change that is done when the combo box default selection is made - so 
that if the user closes the sheet the model variable is still 'nil'.  If the 
user changes the selection then it works as expected.  I tried to addd the 
following line when setting the default selection - thinking that maybe I had 
to change the NSComboBox value via key value selection:

[self setValue:[myDS comboBox:self 
objectValueForItemAtIndex:defaultSelectionIndex] 
                                forKey:@"value"];

but got the following error:
[<AVSComboBox 0x10047b8c0> setValue:forUndefinedKey:]: this class is not key 
value coding-compliant for the key value.
 
I was wondering if anyone had idea on how to fix this?

Thank you,
Mazen Abdel-Rahman
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to