title: instanced variable accessed in class method, Objective C
body: <p>This is the original codes when I am getting this error</p>
  <p>ClassA.h</p>
  <blockquote>
  <p>+(ClassA*)methodA:(NSData*)data;</p>
  <pre><code>@property (nonatomic, strong) NSMutableArray    *arr; 
  @property (nonatomic, strong) RXMLElement     *rxmlRoot; 
  </code></pre>
  <p>@end</p>
  </blockquote>
  <p>ClassA.m</p>
  <blockquote>
  <p>+(ClassA*)methodA:(NSData*)data {</p>
  <pre><code>//NSLog(@&quot;class is %@&quot;,[name class]);
  ClassA *ClassA   =   [[Stores alloc] init];
  arr        =   [NSMutableArray array];
  rxmlRoot   = [RXMLElement elementFromXMLData:data];
  </code></pre>
  <p>}</p>
  </blockquote>
  <p>I am reviewing my codes and now I have tow options to fix the code</p>
  <p><strong>OptionA</strong></p>
  <blockquote>
  <p>ClassA.h</p>
  <pre><code>+(ClassA*)methodA:(NSData*)data;
  
  @property (nonatomic, strong) NSMutableArray    *arr; 
  @property (nonatomic, strong) RXMLElement     *rxmlRoot; 
  
  @end
  </code></pre>
  <p>ClassA.m</p>
  <pre><code>+(ClassA*)methodA:(NSData*)data {
  
  //NSLog(@&quot;class is %@&quot;,[name class]);
  ClassA *ClassA   =   [[Stores alloc] init];
  ClassA.arr        =   [NSMutableArray array];             &lt;----- this has been modified
  ClassA.rxmlRoot   = [RXMLElement elementFromXMLData:data];&lt;----- this has been modified
  
  }
  </code></pre>
  </blockquote>
  <p><strong>OptionB</strong></p>
  <blockquote>
  <p>ClassA.h</p>
  <pre><code>+(ClassA*)methodA:(NSData*)data;
  
  @end
  </code></pre>
  <p>ClassA.m</p>
  <pre><code>static RXMLElement    *rxlRoot; &lt;----- this has been added as class variable
  static NSMutableArray *arr;     &lt;----- this has been added as class variable
  
  +(ClassA*)methodA:(NSData*)data {
  
  //NSLog(@&quot;class is %@&quot;,[name class]);
  ClassA *ClassA   =   [[Stores alloc] init];
  arr        =   [NSMutableArray array];             
  rxmlRoot   = [RXMLElement elementFromXMLData:data];
  </code></pre>
  <p>}</p>
  </blockquote>
  <p>I try either optionA or optionB and the compiler does not complain anything and the codes work properly.</p>
  <p>I see many posts following the optionB which create class variables.</p>
  <p><strong>Question</strong>: is optionA also a good way to follow when we are dealing with class method and class variable as well.</p>
  <p>Please advice me on this issue and by the way if I have made mistakes somewhere, please correct me. Thanks</p>