Re: outlets to multiple views (NSView)
Re: outlets to multiple views (NSView)
- Subject: Re: outlets to multiple views (NSView)
- From: Aaron Boothello <email@hidden>
- Date: Wed, 25 Oct 2006 14:23:34 +0800
Thanks Uli.
When i started programming in Cocoa, i started using the MVC
paradigm. My application is mostly openGL based within the Cocoa API.
When i first started it was recommended that combining the
view&controller. What do you guys reckon ? i dont have any problem
splitting them apart....would it be beneficial ? cause the OpenGL
views do have to interact with the UI.
Cheers,
Aaron
On 21/10/2006, at 8:17 PM, Uli Kusterer wrote:
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