title: Scope of variables Objective C
body: <p>Do variables declared in methods get erased after the method call is done? Ie If i have the method "someMethod" and every time it is called i want to return a different NSString from a stack property will the method return the next object on the stack or will it keep returned the first index since x is erased at the end of the method call. I know if C that variables are erased after function calls, is it the same in objective c? Would using a seperate property for the variable x some this problem? Thanks</p>
  
  <pre><code>(Double) someMethod{
  int x;
  [self.stack objectAtIndex:x];
  x++;
  }
  </code></pre>
  
  <p>After reading the comments I tried creating a property to replace x and here is what I wrote but I get an error warning stating "local declaration of "_location" hides instance variable" What does this mean?</p>
  
  <pre><code>@property (nonatomic) int location;
  @synthesize location=_location;
  
  -(int) location{
      if(!_location){
          int _location = 0;
       //warning is here 
      return _location;
       }
  _location++;
  return _location;
  
  }
  
   (Double) someMethod{
  int x;
  [self.stack objectAtIndex:self.location];
  x++;
  }
  </code></pre>