• 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: Setting Up a MVC most of it works BUT
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting Up a MVC most of it works BUT


  • Subject: Re: Setting Up a MVC most of it works BUT
  • From: Graham Cox <email@hidden>
  • Date: Fri, 10 May 2013 11:57:33 +1000

On 10/05/2013, at 10:35 AM, YT <email@hidden> wrote:

> BUT how does one send data from myDataModel to MyController.
> OR is that by request from MyController only?


Just to elaborate on my previous answer, there are several techniques that are commonly used to update an interface when something in the data model changes. These are, in order of complexity/understandability/history:

a) the data model explicitly calls a method of the controller to tell it about a change. This isn't great, because it sets up a strong dependency between the data model classes and the controller class(es).

a+) the data model declares an informal or formal protocol that some designated object (called a delegate, and this could be your controller) can implement. The data model calls these delegate methods for certain specific activities. This is really just a more elaborate form of a), which is why I call it a+, though with care it can be more generic and anonymous, and therefore can have better decoupling than a.

b) the data model uses the notification center to notify changes, and the controller listens for these notifications.

c) the controller uses key-value observing (KVO) to monitor property changes of the model directly.

d) Bindings, which are built on KVO.


Searching the documentation with these terms should yield the relevant information.


--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

  • Follow-Ups:
    • Re: Setting Up a MVC most of it works BUT
      • From: Jens Alfke <email@hidden>
References: 
 >Setting Up a MVC most of it works BUT (From: YT <email@hidden>)

  • Prev by Date: Re: Can scroll direction be changed programmatically?
  • Next by Date: setFrame: weirdness in UITableViewCell
  • Previous by thread: Re: Setting Up a MVC most of it works BUT
  • Next by thread: Re: Setting Up a MVC most of it works BUT
  • Index(es):
    • Date
    • Thread