On Jul 8, 2016, at 05:36 , Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> wrote: > > My setter code currently looks like this: > > -(void)setGlobalChannelEnableState:(NSInteger)state
In the circumstances you describe, a setter method is effectively an action method, not a setter — that is, it becomes a method that’s called when your code needs to do something, rather than a way to set some state. As you’ve found, the real setter method tends to work against you here, because you have to figure out what the binding expects with the changed value it thinks it’s setting. So, I think a cleaner approach is to leave out the setter method entirely, and use a real action method instead. With no setter, the binding won’t try to update the property, it’ll basically be read-only. When the checkbox is clicked, the action method is still invoked — it’s a NSButton, after all. All the action method has to do is retrieve the current global state via the getter, then set the individual states needed to flip it, sandwiched between one pair of will/didChange calls for the key “globalChannelEnableState”. You don’t need to dispatch anything to a later iteration of the main event loop. (Even in your current code — the setter will automatically generate the KVO notification, so doing it again later is redundant.) _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com