title: Public scope in Objective-C?
body: <p>I’m sure this is a simple one, but it’s been elusive so far, and I’m stumped ...</p>
  
  <p><strong>How do I declare an Ivar so that it’s accessible from ALL Classes in a project?</strong></p>
  
  <p>[Don’t know if it matters, but the ivar in question is (an instance of) my Model class, whose data needs to be accessible to various view controllers.]</p>
  
  <p>Best as I can tell from <a href="http://developer.apple.com/DOCUMENTATION/Cocoa/Conceptual/ObjectiveC/Articles/ocDefiningClasses.html#//apple_ref/doc/uid/TP30001163-CH12-TPXREF127" rel="noreferrer">"The Scope of Instance Variables”</a> in <i>The Objective-C 2.0 Programming Language</i> 
  ... this would be by using the “@public” directive.</p>
  
  <p>So I’ve tried this in the @interface block where the ivar is declared: </p>
  
  <pre><code>@interface ...
  
  ...
  
  @public
  ModelClass *theModel;
  
  @end
  </code></pre>
  
  <p>... But when I try to refer to “theModel” in a different class, the compiler doesn’t auto-complete, and when I type it in anyway, the compiler shows:
  “Error: ‘theModel’ undeclared (first use in this function)”.</p>
  
  <p>I assume this is a question of Scope, and that I haven’t made the ivar available appropriately, but how?  Somehow I need to access this, or make its pointer available somehow.</p>
  
  <p>Any ideas would be VERY much appreciated.  Many thanks!</p>