Re: Programmatically replace bound objects
Re: Programmatically replace bound objects
- Subject: Re: Programmatically replace bound objects
- From: Claudio Procida <email@hidden>
- Date: Fri, 18 Aug 2006 19:06:17 +0200
Il giorno 18 ago 2006, alle ore 17:57, Matt Neuburg ha scritto:
And ka-blam! arrayWithObjects generates an autoreleased object, so
that
array vanishes in a puff of smoke a few nanoseconds later.
erh... #^_^# well, I didn't tell all the truth.
My actual code is different and more complex than that, as the array
is returned by a custom NSArray category.
As I told, the NSPopupButton is bound to a NSArray(Controller, ok!).
It contains a sequence of elements, say
"a", "b", "c", "d", "e".
When the user selects a value, let's say "e", I want to replace its
contents with
"c", "d", "e", "f", "g"
I use it as a rudimentary navigation menu. Got it? Ok
Since I had not only to replace the menu contents, but even adjusting
the selected index, for some reason I thought this would trigger the
menu action once again, resulting in an infinite loop.
Now I'm realizing that setting the selected item doesn't cause the
action to be invoked, so I guess you helped me to completely solve my
problem :)
I do not at all understand, either, why you are removing the action
and
target and binding and restoring them.
that was part of my "trial-and-error" testing for the reason above.
Simply replace the value of "days" in
a KVO-compliant way, and the binding will see it (the "O" stands for
"observe", that's the whole point).
ok
Finally, as a general rule, do not bind the NSPopupButton to "a
NSArray
member of a controller object". Bind it to an NSArrayController,
and bind
*that* to your object that contains the "days" array.
I'll do as you suggest -- now it works like a charm; anyway I'd love
to understand what was wrong with my code, or better, learn the right
way of doing that.
Thank you
Claudio
--
http://www.emeraldion.it
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden