Re: Setting Up a MVC most of it works BUT
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