• 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: Sharing NSViews
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sharing NSViews


  • Subject: Re: Sharing NSViews
  • From: "c. mendoza" <email@hidden>
  • Date: Fri, 8 Aug 2008 22:03:12 -0400

That is a good point... my data is indeed separate from the view, all that needs synchronization is a couple of custom controls, which could perhaps be handled via notifications.

thanks,

c.


On Aug 8, 2008, at 9:56 PM, Graham Cox wrote:


On 9 Aug 2008, at 11:44 am, c. mendoza wrote:

Why do you think you need to do this anyway? If you have a view class just create a new instance of it.


Because the two views should be synchronized

If you need to go out of your way to "synchronise" two views, maybe your design could do with a bit of revision to use better MVC principles. Normally a view wouldn't have state data that required synchronisation. Instead, the (single) model contains the state data and the views just visualise it. When the model changes, the views are redrawn and thus both show the same data.


If you are keeping state data in your view, move it into a model class and use a controller to mediate between the two views and the model. While it seems more complicated at first, it's well worth it because it makes the two-view scenario trivial to deal with. A good rule of thumb is that if you ever need to duplicate or synchronise the same data in two places, your design is wrong.

hth,

Graham

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >NSSearchField bindings almost work (From: Dustin Robert Kick <email@hidden>)
 >Sharing NSViews (From: "c. mendoza" <email@hidden>)
 >Re: Sharing NSViews (From: Graham Cox <email@hidden>)
 >Re: Sharing NSViews (From: "c. mendoza" <email@hidden>)
 >Re: Sharing NSViews (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Sharing NSViews
  • Next by Date: When the getter returns a BOOL, is "is" the preferred prefix?
  • Previous by thread: Re: Sharing NSViews
  • Next by thread: Re: Sharing NSViews
  • Index(es):
    • Date
    • Thread