Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simple Cocoa bindings question



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: Simple Cocoa bindings question (From: Matt Neuburg <email@hidden>)
 >Re: Simple Cocoa bindings question (From: Roland Torres <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.