On Sep 29, 2010, at 6:31 AM, Jonny Taylor wrote:

> I have a modal dialog which, among other things, contains a number of file 
> paths. There are "set..." buttons to set which files these are pointing to.

You should probably by using NSPathControl instead of displaying paths and 
having "set" buttons.

> I feel that with bindings I should be able to set things up automatically in 
> InterfaceBuilder so that when that button is clicked a nav dialog is 
> presented [ok, I'll probably need a subclass and/or custom action for that 
> part...], and the appropriate bound parameter in my model is updated with the 
> new path as chosen by the user.

Bindings aren't magic and they aren't the right solution to every problem.

Buttons should typically use the target-action mechanism to perform their 
purpose.  Just have each button deliver an appropriate message to the 
controller and have the controller update the model.  It's the simplest and 
cleanest approach.

Remember that today you just have a button to perform this action.  Tomorrow or 
in some other context, you may have a toolbar button or a menu item or want to 
invoke the functionality programmatically.  Etc.  Rigging everything up so the 
details of what gets done are stored in the button and its connections is the 
less general solution.  Put the smarts in the controller where they belong and 
they can be reused later.

Just about the only properties of a button (or other control) that are safe to 
use for a purpose such as this are the action, the target, and the tag.  If you 
really want, you can have multiple buttons all invoke the same action method on 
the same target and then have that method operate slightly differently based on 
the sender's tag.  I think you'll find that, in most cases, it's not an 
improvement over just using a separate action method per button.

Regards,
Ken

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to