• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: outlets to multiple views (NSView)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: outlets to multiple views (NSView)


  • Subject: Re: outlets to multiple views (NSView)
  • From: Mike Abdullah <email@hidden>
  • Date: Sat, 21 Oct 2006 20:45:02 +0100

Definitely, or even make use of Key Value Observing instead of NSNotifications.

Mike.
On 21 Oct 2006, at 13:17, 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:
40gmail.com


This email sent to email@hidden

_______________________________________________ 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
References: 
 >outlets to multiple views (NSView) (From: Aaron Boothello <email@hidden>)
 >Re: outlets to multiple views (NSView) (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: making small pdfs
  • Next by Date: Text character under the mouse cursor in an NSTextView
  • Previous by thread: Re: outlets to multiple views (NSView)
  • Next by thread: Re: outlets to multiple views (NSView)
  • Index(es):
    • Date
    • Thread