title: Objective-C property assignment returns the assigned value?
body: <p>Say I have the following:</p>
  
  <pre><code>@interface MyClass : NSObject { NSString* _foobar; }
  @property (nonatomic, retain) NSString* foobar;
  @end
  
  @implementation MyClass
  @dynamic foobar;
  - (void) setFoobar:(NSString*)fbSet; { [_foobar release]; _foobar = [fbSet retain]; }
  - (NSString*) foobar; { return _foobar; }
  @end
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>MyClass* mcInst = [[[MyClass alloc] init] autorelease];
  NSLog(@"I set 'foobar' to '%@'", (mcInst.foobar = @"BAZ!"));
  </code></pre>
  
  <p>Looking at the return value of <code>-[MyClass setFoobar:]</code>, one might assume here that this line would print <code>I set 'foobar' to ''</code>, because the assignment appears to return nothing.</p>
  
  <p>However - thankfully - this assignment acts as expected, and the code prints <code>I set 'foobar' to 'BAZ!'</code>. Unfortunately, this feels like a contradiction, because the invoked setter's return value belies the fact that the assignment returns the value assigned to it. At first I figured that <code>mcInst.foobar = @"BAZ!";</code> is making two calls instead a block: first the setter and then the getter to gather the return value. However, instrumenting the setter and getter methods with <code>NSLog</code> calls proves this isn't the case.</p>