Saturday, October 5, 2013

Combination of MVC and kvo

I want to do a little game, with the MVC pattern

M and C linked through kvo, M changes, V be notified
I do not quite understand is, V change, M be notified updated M, M is modified, then do not turn notify C to update V do? This is not to become a cycle yet
Reply:
1. View triggered by a button in the view controller via IBOutlet call the corresponding action
2 In the action to get some label.text modified model
3. Model modified by kvo updated UI, where the UI does not include the trigger source

In other words, the trigger of the view controller is no need to observe model, just outside the associated changes in model view controller to get the issues, so usually in kvo adding a source, if self == source direct return swap, which means that you have dealt with before.
Reply:
1. Button click to update notification C M in labeltext
2. Labeltext change notification through kvo label C to update the UI

You said judgment source == self is what step to do?
And here's self is what object?


Reply:
MVC is a pattern, which is relative to the framework for the entire project, not an object, a key question of the relationship;
KVO is technical, it means adding an observer only, the observer is to observe him the value of the monitored key value is changed, changing the operation to do what you do operations, regard him as the MVC pattern is the concept of fuzzy problems ;

No comments:

Post a Comment