Re: outlets to multiple views (NSView)
Re: outlets to multiple views (NSView)
- Subject: Re: outlets to multiple views (NSView)
- From: Uli Kusterer <email@hidden>
- Date: Sat, 21 Oct 2006 14:17:41 +0200
Am 21.10.2006 um 12:30 schrieb Aaron Boothello:
I have an application with 4 different views of a 3D scene. The
views are NSOpenGLViews. They are "connected" to each other using
outlets.
My goal is to be able to update the views whenever something is
changed in any one of them. So i am keeping track of which view i
am making the change in and accordingly updating the other 3 views
by calling this method:
[view1 setNeedsDisplay:YES];
[view2 setNeedsDisplay:YES];
etc
Don't do that. Cocoa uses the model-view-controller paradigm, which
offers a much better solution to this:
Use NSNotifications instead. Create a model object that takes care
of managing the data. Each view, when edited, only tells the model
how to change. When the model is changed, it sends an NSNotification
that it was changed, and all your views subscribe to that
notification. That way, whenever the model changes, whether it be
under code control or through a view, or through a numeric edit field
in an inspector, all views you have (and even aforementioned numeric
edit fields) will know and can update as needed.
Cheers,
-- M. Uli Kusterer
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden