• 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
Re: Programmatically replace bound objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Programmatically replace bound objects
      • From: Claudio Procida <email@hidden>
  • Prev by Date: Re: copy versus arrayWithArray:
  • Next by Date: Re: NSPopUpButton inside Table CornerView
  • Previous by thread: Programmatically replace bound objects
  • Next by thread: Re: Programmatically replace bound objects
  • Index(es):
    • Date
    • Thread