title: Difference between class property mVar and instance variable self.mVar
body: <p>I am some what confused as to the difference between accessing an instance variable via self or just by name (when working inside the class).</p>
  
  <p>For instance, take this class:</p>
  
  <pre><code>//In .h file:
  @interface Register : NSObject {
      NSString *mName;
  }
  
  - (id) initWithName:(NSString *) name;
  
  //In .m file:
  - (id) initWithName:(NSString *)name
  {
      if (self == [super init])
      {
          mName = name;
      }
      return self;
  }
  </code></pre>
  
  <p>What's the difference between accessing the instance variable via</p>
  
  <pre><code>self.mName = name;
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>mName = name;
  </code></pre>
  
  <p>Which isn't a @property and is not @sythenize'd.</p>
  
  <p>Say it is this though, per this example:</p>
  
  <pre><code>//In .h file:
  @interface Manange_My_ViewsViewController : UIViewController { 
      IBOutlet UILabel *countLabel;
  }
  
  @property (nonatomic, retain) IBOutlet UILabel *countLabel;
  
  //In .m file:
  @synthesize countLabel;
  
  - (void) updateLabel:(NSUInteger)count
  {
      countLabel.text = [NSString stringWithFormat:@"%d", count];
  }
  </code></pre>
  
  <p>But say I accessed countLabel as:</p>
  
  <pre><code>self.countLabel
  </code></pre>
  
  <p>What would be the difference?</p>
  
  <p>Edit: Third example per users' answer:
  Say it the iVar wasn't an IBOutlet:</p>
  
  <pre><code>//In .h file:
  @interface Fake : NSObject {
      NSString *mVar;
  }
  @property (nonatomic, retain) NSString *mVar;
  
  //In .m file:
   @synthesize mVar;
  
   mVar = @"";
  </code></pre>
  
  <p>VS</p>
  
  <pre><code> self.mVar = @"";
  </code></pre>
  
  <p>Or is it the same - that in the first we are accessing the actual instance variable and in the second we're actually going through the auto created setter (via @synthesize)?</p>
  
  <p>Thanks all!</p>
  
  <p>Edit: Update in response to Peter Hosey ...</p>
  
  <p>So your thinking the convention of mVarName is bad? I took that from my C++ days.</p>
  
  <p>But what about the case when you do?</p>
  
  <pre><code>-(void) someMethod:(int) x
  {
      x = x;
  }
  </code></pre>
  
  <p>You can't do that (Say 'x' is also a class variable)</p>
  
  <p>But you can do:</p>
  
  <pre><code>-(void) someMethod:(int) x
  {
      mX = x;
  }
  </code></pre>
  
  <p>But your saying its better to do:</p>
  
  <pre><code>-(void) someMethod:(int) x
  {
      self.x = x;
  }
  </code></pre>