Re: Binding NSPopupButton crashes
Re: Binding NSPopupButton crashes
- Subject: Re: Binding NSPopupButton crashes
- From: Steve Checkoway <email@hidden>
- Date: Mon, 15 Oct 2007 13:03:09 -0700
Matt Neuburg wrote:
On Mon, 15 Oct 2007 11:17:19 -0700, Steve Checkoway <email@hidden> said:
I am trying to bind an NSPopupButton to the user defaults in Interface
Builder as well as programatically binding a property in another class
to the same user default value.
You're trying to bind *what* about the NSPopupButton? Remember, lots of
things about a popup button are bindable; and three things about a popup
button are usually bound if you're going to bind any of them.
I suspect (though this is just a guess, because you have not given any
information) that what you are thinking of binding is the selectionIndexes
I said what I was binding in the email you quoted. "In IB, I'm binding
the selected value of the popup button to the shared user defaults
controller with the key path "values.foo"." It's the selected value.
(i.e. you want user defaults to preserve a knowledge of what the user has
selected in the popup menu). But if that is all you are binding, then you
must do it after the popup button's menu is populated or you'll crash.
Furthermore, selectionIndexes is a set, whereas what you want to store in
user defaults is probably a number. It might be better to do this binding in
code, because then you can be in charge when the binding goes into effect,
and you can use a value transformer to mediate the between the set and the
number.
No, the selected value is a string and it's being stored correctly, as
long as I don't have the programatic binding. Originally, I was storing
an integer and I did have a value transformer to go between the string
value and the integer. It worked fine except when I had the two bindings
in which case I got the same crash so I changed everything to be a
string in order to debug without the value transformer.
Programatically, I have the following.
But that is completely uninformative, since we don't know what values.foo
is. What kind of value is it, and how are you binding from the popup button
to that value?
values.foo is a string. I'm binding it using interface builder by
checking the selected value binding box, choosing the shared user
defaults controller, and setting the path to values.foo.
This part is working by itself. When I change the selection, the value
of the selection (i.e., the string) gets written to the user defaults
which I can see using defaults(1).
It's only when I have the programatic binding as well that it crashes.
--
Steve Checkoway
_______________________________________________
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