Re: Simple Cocoa bindings question
Re: Simple Cocoa bindings question
- Subject: Re: Simple Cocoa bindings question
- From: Chris Hanson <email@hidden>
- Date: Wed, 28 Mar 2007 20:59:35 -0700
On Mar 28, 2007, at 12:11 PM, Roland Torres wrote:
If that's the way it works, that's okay. I guess I was wondering if
Cocoa bindings could also initiate the action associated with the
switch when it sets it to the ON state, as though it were clicked,
as opposed to me checking for the state of the switch in code, and
then invoking the action method directly.
Cocoa bindings won't initiate the action; it really only deals with
ensuring that model and view objects are kept in sync.
In this case, rather than have an operation in your software which is
initiated as a result of an action message, instead you might want to
have that operation initiated as a result of the state transition in
your model object. You can do this either by having whatever performs
the operation observe the property, or by having the object the
property is a part of inform whatever performs the operation in
question (either directly or via a notification).
This way it doesn't matter at all how the transition occurs -- whether
it's a result of Cocoa bindings syncing a property to a change in view
state (e.g. clicking a checkbox), whether it's some other piece of
code setting the property, or even Cocoa scripting causing the
property to be changed.
-- Chris
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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