Re: Binding NSSegmentedControl selection to user defaults
Re: Binding NSSegmentedControl selection to user defaults
- Subject: Re: Binding NSSegmentedControl selection to user defaults
- From: Keary Suska <email@hidden>
- Date: Wed, 29 Aug 2012 08:15:24 -0600
On Aug 29, 2012, at 3:50 AM, Motti Shneor wrote:
> Hi Keary and thanks.
>
> I don't quite understand - do you mean by "registering" my key, Adding an entry to my Application's preferences file (.plist) ? If so --- than I tried that, but I did not know what exactly to write there.
>
> In addition I unchecked the "Raises for Not Applicable Keys" option specifically for that --- I want the segmented control to create the entry the first time I set its selection programmatically.
>
> This thing works flawlessly with other kinds of controls (NSbuttons), when I bind their value to the "Shared User Defaults Controller.values.myButtonState".
>
> Or maybe I miss something important here?
Look in the user defaults docs for "registering default values." Although you shouldn't need to in this case--as you saw an NSButton had no issue--but I have seen similar errors in bindings when an unexpected value is returned by a model object.
So, I am not saying that you have to do this, I am saying that the first course of action is to guarantee that the value is explicitly and predictably defined before you use it. You can't debug what you don't know.
> On 28 באוג 2012, at 21:53, Keary Suska wrote:
>
>>
>> On Aug 28, 2012, at 9:28 AM, Motti Shneor wrote:
>>
>>> 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".
>>
>> Did you register "mySegmentedControlSelection" with user defaults as specified by the docs for using user defaults?
>>
>>> 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.
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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