• 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 NSSegmentedControl selection to user defaults
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding NSSegmentedControl selection to user defaults


  • Subject: Binding NSSegmentedControl selection to user defaults
  • From: Motti Shneor <email@hidden>
  • Date: Tue, 28 Aug 2012 18:28:49 +0300

Hello everyone.

I'm trying to do something simple --- to have an NSSegmentedControl (2 segments) save and restore its selection (the "pressed" segments) from the user-defaults.

Documentation seems to be quite clear: Cocoa Bindings Reference: NSSegmentedControl Bindings
-----------------------------------
selectedIndex
An integer value that specifies the index of the selected item in the NSSegmentedControl. When the selection changes in the NSSegmentedControl, this value is updated with the index of the newly selected item.

Availability: OS X v10.3 and later.

Binding Options
Option	Binding option constant	Value class
Allows Editing Multiple Value Selection	NSAllowsEditingMultipleValuesSelectionBindingOption	NSNumber (Boolean)
Always Presents Application Modal Alerts. Available in OS X v10.4 and later.	NSAlwaysPresentsApplicationModalAlertsBindingOption	NSNumber (Boolean)
Conditionally Sets Enabled	NSConditionallySetsEnabledBindingOption	NSNumber (Boolean)
Conditionally Sets Hidden	NSConditionallySetsHiddenBindingOption	NSNumber (Boolean)
Raises for Not Applicable Keys	NSRaisesForNotApplicableKeysBindingOption	NSNumber (Boolean)
Validates Immediately	NSValidatesImmediatelyBindingOption	NSNumber (Boolean)
-----------------------------------

But when I'm trying to do this in my XCode 4.2 project, in a .xib file, I experience several problems, and finally a crash on loading the .xib file.

1. In Interface builder, only one of the binding options appears for NSSegmentedControl (Raises for Not Applicable Keys) all the rest are simply not there.

2. I have bound my NSSegmentedControl's "selectedIndex" to the "Shared User Defaults Controller.values.mySegmentedControlSelection" key, but the application crashes as I load the .xib file, claiming that NSSegmentedControl is not key-value-coding compliant with the key "selectedIndex".

3. BTW, my segmented control is configured for "Any" meaning, multiple segments can be selected concurrently. However, changing this to only single selection did not cure the crash.


Any ideas?

Motti Shneor


_______________________________________________

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 NSSegmentedControl selection to user defaults
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: CALayer show/hide question when moving to full screen.
  • Next by Date: Re: Binding NSSegmentedControl selection to user defaults
  • Previous by thread: Re: CALayer show/hide question when moving to full screen.
  • Next by thread: Re: Binding NSSegmentedControl selection to user defaults
  • Index(es):
    • Date
    • Thread