开发者

Cocoa: Changing object property from different menu items

What's the rule of thumb if I want to change observed object's sin开发者_运维知识库gle 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜