title: iPhone MVC app: Where should I put the model?
body: <p>I'm pretty new to iPhone development.</p>
  
  <p>I am building an app which has multiple views and controllers.  There is only one model.</p>
  
  <p>I need to share the model amongst all of the controllers; so I have instantiated the model inside the App Delegate header file:</p>
  
  <pre><code>@interface MyAppDelegate
  (...snip...)
  @property (nonatomic, retain) CalcModel *model;
  </code></pre>
  
  <p>and then synthesized it accordingly.</p>
  
  <p>Inside a controller, I have tried to reference the model like so:</p>
  
  <pre><code>CalcModel* model = [[[UIApplication sharedApplication] delegate] model];
  </code></pre>
  
  <p>The problem is that the compiler says '-model' not found in protocol</p>
  
  <p>This is probably because the delegate field returns the protocol type, not the concrete MyAppDelegate type...  so should I cast [[UIApplication sharedApplication] delegate] to MyAppDelegate, so I can access the model property? If so, how?</p>
  
  <p>Or is this all wrong?  More broadly, how would you share a model amongst view controllers?</p>
  
  <p>many thanks for your help</p>