• 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
Binding -- or not -- a button created in code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binding -- or not -- a button created in code


  • Subject: Binding -- or not -- a button created in code
  • From: Jerry Krinock <email@hidden>
  • Date: Mon, 21 Jun 2010 00:14:05 -0700

In a home-made "collection view", each item contains a checkbox, whose value should represent an attribute in the data model.

Looking at this from a high level, it seems there are two ways to wire its value

1.  The *modern* way is to -bind::: it to the model when it is created, and -unbind:: it when it is removed from the view permanently.  The unbinding can be tricky because "removal" can occur if the item is removed from the collection, or replaced for some reason, or when the window closes.  I must be careful to unbind once and only once.  I seem to remember that doing this kind of thing in -dealloc is not recommended.

2.  If I am *sure* that no other control, code, future feature, plug-in, or script could ever change the model value, I can "simply" wire up its value the *old-fashioned* way, setting it to the current model value upon creation, and wiring its target/action to a method which changes the model.  The trick here is if I am really *sure* none of this stuff could ever happen.

Any mistakes or omissions in this?

Jerry Krinock

_______________________________________________

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

  • Follow-Ups:
    • Re: Binding -- or not -- a button created in code
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Getting Computer Name
  • Next by Date: Re: Binding -- or not -- a button created in code
  • Previous by thread: Re: AppleScript in a Cocoa app
  • Next by thread: Re: Binding -- or not -- a button created in code
  • Index(es):
    • Date
    • Thread