My app toolbar design pattern is as follows. My question concerns the nature of this design.
1. The App has four or five window subclasses, each with separate, dynamic, toolbars. 2. Most of the toolbar items are views. 3. A toolbar controller factory class generates instances of toolbars for a particular window. 4. Each toolbar item has its own controller class as a target. When a tool bar item is selected an action is sent to the item's controller target for initial decision making. The controller then generally dispatches a notification. I have not used KVO, nil targeted actions or delegates here for several reasons: 1. In may cases the ultimate receiver is deep down in the object hierarchy and obtaining the delegate reference/observer target can involve traversing a lot of classes. 2. NSViewController is not part of the responder chain (though I know the chain can be customised to permit this) which makes nil targeting less effective. (in the absence of custom NSView subclasses the action has to hit the window, window delegate, or App delegate before it can be retargeted) 3. Some of the application views are reused in several different windows with different toolbars. Notifications don't care about the receiver's relative position. The notification based system does work but seems heavy handed when compared to say the elegance of the responder chain. Eg: MyAppChangeViewConfigRequest notifications are sent from the tool bar to change the application's view configuration. If and when the view configuration request succeeds a MyAppDidChangeViewConfig notification is sent out. If the view configuration is changed from the menu then the same MyAppChangeViewConfigRequest and MyAppDidChangeViewConfig notifications are sent. Tool bar items, via their controller, observe the MyAppDidChangeViewConfig notification and update their state accordingly. On the other hand a notification based system is flexible. I can move the notification's receiver about in the class hierarchy while developing without worrying about the receiver's accessibility as a target or wether I have broken the responder chain. If another view needs to get in on the act then it just becomes another observer of the MyAppDidChangeViewConfig notification. My question is, is the use of notifications common in toolbar implementation or have I missed a trick by not sticking firmly to targeted actions, nil or otherwise? Do other developers find implementing moderately complex toolbar subsystems challenging? Sorry this is long. Regards Jonathan Mitchell Developer http://www.mugginsoft.com Regards Jonathan Mitchell Developer http://www.mugginsoft.com _______________________________________________ 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