• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
binding NSComboBox default selection
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

binding NSComboBox default selection


  • Subject: binding NSComboBox default selection
  • From: "Mazen M. Abdel-Rahman" <email@hidden>
  • Date: Thu, 07 Jan 2010 10:02:33 -0700

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 (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

  • Follow-Ups:
    • Re: binding NSComboBox default selection
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: iPhone: validate a NSString for US zipcode
  • Next by Date: Is it possible to change the color of selected columns in NSTableView?
  • Previous by thread: Re: Julian date
  • Next by thread: Re: binding NSComboBox default selection
  • Index(es):
    • Date
    • Thread