On 19 Oct 2010, at 10:01 PM, Sandro Noël wrote: > I am wondering if there is a way to ask the currently topmost windows > controller to show a view... > from a descendant of NSObject that has no clue of the view stack, > > if so, how do I get a reference to that view controller from that NSObject > Descendant?
That an object — presumably a model object — should concern itself specifically with what views a window is to display, is a huge breach of the Model-View-Controller design pattern. You should consider a less accident-prone design. However, if you simply mean that you want the view _controller_ to know about changes to the model, and adjust the views accordingly, you have three options: - Make sure the model changes itself only in key-value-compliant ways, and have the controller observe it. - Have the model post NSNotifications at all interesting events, and have the controller observe them. - Code up a singleton "broker" object that can receive the notifications or KVO events, or even specific method calls, from the model object, and then use its knowledge of the window stack to get the frontmost window that has a controller (maybe [NSApp {key,main}Window] suffices, or maybe it listens to NSWindowDidBecome{Key,Main}Notification), and then try to send your intended "show a view" message to its controller. Assuming you will never add a window controller that doesn't implement that message. I'm not going out of my way to make that sound fragile and hard-to-maintain. — F _______________________________________________ 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