title: CS193P Assignment 3, Hint#5 - What is the model?
body: <p>I am working my way through the Stanford Fall 2011 iOS course:
  <a href="http://www.stanford.edu/class/cs193p/cgi-bin/drupal/" rel="nofollow">http://www.stanford.edu/class/cs193p/cgi-bin/drupal/</a></p>
  
  <p>I am onto assignment#3:
  <a href="http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/assignments/Assignment%203_2.pdf" rel="nofollow">http://www.stanford.edu/class/cs193p/cgi-bin/drupal/system/files/assignments/Assignment%203_2.pdf</a></p>
  
  <p>As a summary, prior assignments have asked to build a regular calculator and now this assignment is asking us to push this calculator unto a Nav controller and create a segue from that CalculatorViewController to a GraphViewController that would plot the function stored in the "CalculatorBrain". This CalculatorBrain was the model for the original CalculatorViewController.</p>
  
  <p>Hint#5 keeps on talking about the fact that now the model for the GraphViewController is different than the model of the CalculatorViewController and I can't figure out what he means by that.</p>
  
  <p>The only way I have been able to build the new MVC is by creating a protocol in the GraphView (view) of the GraphViewController with an object called "dataSource" of type ID. And then in the GraphViewController: adopting that protocol, instantiating the GraphView and setting itself as the datasource:</p>
  
  <pre><code>-(void) setGraphView:(GraphView *)graphView
    {
    _graphView=graphView;   
    self.graphView.dataSource=self;
    }
  </code></pre>
  
  <p>And then in the original CalculatoViewController, using the prepareForSegue to pass the program to the GraphViewController:</p>
  
  <pre><code>-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
    if([segue.identifier isEqualToString:@"Graph"])
    {
      GraphViewController *myGraphViewController = segue.destinationViewController;
      myGraphViewController.myCalculator=self.myCalcBrain;
    }
  }
  </code></pre>
  
  <p>So that seems to work fine. So if that works, that means that the GraphViewController's model is really the original Calculator Brain that he specifically said it is not!</p>
  
  <p>I mean isn't the fact that, during the segue, I am assigning to the Graphviewcontroller calculator property the calculator model instance from the original CalculatorViewController and then using a protocol to return the Y value from the GraphViewController to the GraphView means that the model for the GraphViewController is really just the original CalculatorBrain model.</p>