Reputation: 1970
How do I exactly implement MVC design pattern to my code?
Now where do I implement View? Am I missing something?
Upvotes: 0
Views: 389
Reputation: 62686
Your ViewController should observe changes to the model and update it's view hierarchy, whose root is self.view
.
- (void)viewDidLoad {
[super viewDidLoad];
// observe the model, via kvo, or subscribe to notification, or make self == somebody's delegate, etc.
}
- (IBAction)doSomething:(id)sender {
// change the model [self.model change]
// or start a web request with self as delegate
}
// called by kvo or delegate or notification or [self modelDidChange];
- (void)modelDidChange {
// update self.view or children viewWithTag: or outlets setup to subviews
}
Upvotes: 2