0

How do I exactly implement MVC design pattern to my code?

  1. Controller -> Call Rest Service with RestKit.
  2. Bind the JSON to a Object --> Which is A model
  3. Controller display bunch of data based on the model.

Now where do I implement View? Am I missing something?

2

1 Answer 1

2

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
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.