views:

17

answers:

1

What's the rule of thumb if I want to change observed object's single property from different menu items (think - list of options).

E.g. I have an app that displays a car in a single window. I have a menu with menu item that says [Colors] with few submenu items like [Black, Green, Blue, Red, White, etc.]. How do I implement the mechanism behind this so that each submenu item changes same property (in this case - color) to different values.

+1  A: 

If you're using target-action (IBAction) just point the menu at the same method in the same object and have the method make the appropiate changes.

If you're using bindings, then you set the keypath to the same attribute.

TechZen
Ok, how do I pass needed parameter value from menu item to the action (using target-action)?
Eimantas
The menu passes itself to the method when it sends the action message. Have the method check with menu sent the action and respond accordingly. See http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/MenuList/Articles/ManagingPopUpItems.html#//apple_ref/doc/uid/20000274-BAJDEEJA
TechZen
Thank you very very much for this answer and link!
Eimantas