如何在我的代码中完全实现MVC设计模式?
现在我在哪里实现View? 我错过了什么吗?
答案 0 :(得分:2)
您的ViewController应观察模型的更改并更新其视图层次结构,其根目录为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
}