Re: Programmatically replace bound objects
Re: Programmatically replace bound objects
- Subject: Re: Programmatically replace bound objects
- From: Matt Neuburg <email@hidden>
- Date: Fri, 18 Aug 2006 08:57:30 -0700
- Thread-topic: Programmatically replace bound objects
On Fri, 18 Aug 2006 01:00:00 +0200, Claudio Procida <email@hidden>
said:
>Hi,
>
>I have a NSPopupButton whose content is bound to a NSArray member of
>a controller object. The binding has been set through IB.
>
>Now I'm trying to replace the array programmatically, but something
>goes wrong, as I get an EXC_BAD_ACCESS error.
> [self setDays:[NSArray arrayWithObjects:@"1", @"2", nil]];
And ka-blam! arrayWithObjects generates an autoreleased object, so that
array vanishes in a puff of smoke a few nanoseconds later.
I do not at all understand, either, why you are removing the action and
target and binding and restoring them. 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).
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.
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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