Binding -- or not -- a button created in code
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