title: Best way of declaring private variables in cocoa
body: <p>I would like to know what the recommendations are for declaring private instance variables in cocoa. This question is in the context of developing apps on the iPhone.  </p>
  
  <p>I am aware of at least three ways of declaring private variables:</p>
  
  <ol>
  <li><p>Declare them in the interface of the h file with the modifier @private:</p>
  
  <pre><code>@interface MyClass : NSObject {  
    @private  
    NSObject * myPrivateVar;   
  }
  </code></pre></li>
  <li><p>Declare them in the implementation section of the m file:  </p>
  
  <pre><code>@implementation MyClass  
  NSObject * myPrivateVar;
  </code></pre></li>
  <li><p>Declare a property in the interface of the m file (not even declaring the variable itself):  </p>
  
  <pre><code>@interface MyClass ()  
  @property (nonatomic, retain) NSString* myPrivateVar;  
  @end  
  @implementation  
  @synthesize myPrivateVar;
  </code></pre></li>
  </ol>
  
  <p>So far, I have used extensively 2 but recently came to realize this might be dangerous due to the lack of garbage collection.  Are there cases where it remains perfectly acceptable to use that method?</p>
  
  <p>Is 3 more appropriate?  Does the answer depend on the object type (e.g. mutable/immutable)?</p>
  
  <p>Pointers to reference material discussing the trade offs for using/not using properties in general also appreciated.</p>