title: iOS ARC - weak and strong properties
body: <p>I'm trying to understand the way ARC works, and as far as I know, I should be doing something wrong here. This is the code I'm using:</p>
  
  <p><strong>Interface:</strong></p>
  
  <pre><code>@interface ViewController : UIViewController{
  
  }
  
  @property (strong, nonatomic) NSString * myString ; 
  @property (weak, nonatomic) NSString * myPointer ;
  </code></pre>
  
  <p><strong>Implementation:</strong></p>
  
  <pre><code> - (void)viewDidLoad{
  
       [super viewDidLoad];
       self.myString = @"Hello world!" ; // myString is strong
       self.myPointer = self.myString ; // myPointer var is weak
  
       [self performSelector:@selector(makeNilMyValue) withObject:nil afterDelay:1];    
       [self performSelector:@selector(printValues) withObject:nil afterDelay:2];    
  }
  
   - (void) makeNilMyValue{
       self.myString = nil ; 
  }
  
   - (void) printValues{
       NSLog(@"myString: %@", self.myString) ;
       NSLog(@"myPointer: %@", self.myPointer) ; 
   }
  </code></pre>
  
  <p>After executing this, I get:</p>
  
  <pre><code>2012-02-26 11:40:41.652 test1[933:207] myString: (null)
  
  2012-02-26 11:40:41.653 test1[933:207] myPointer: Hello world!
  </code></pre>
  
  <p>If I'm not wrong, due to myPointer is weak, it shouldn't retain the content of the object. So, it should show nil instead of "Hello World!".</p>
  
  <p>What am I doing wrong? </p>
  
  <p><strong>Following Caleb's answer, I have created another weak pointer, see code below:</strong></p>
  
  <pre><code>- (void)viewDidLoad{
      [super viewDidLoad];
      self.myString = @"Hello world!" ; // myString is strong
      self.myPointer = self.myString ; // myPointer var is weak
      self.myPointer2 = self.myString ; // myPointer2 var is weak
  
      [self performSelector:@selector(makeNilMyValue) withObject:nil afterDelay:1];    
      [self performSelector:@selector(printValues) withObject:nil afterDelay:2];    
  }
  
  - (void) makeNilMyValue{
      self.myPointer2 = @"value changed!" ;
      self.myString = nil ;
  
  }
  
  - (void) printValues{
      NSLog(@"myString: %@", self.myString) ;
      NSLog(@"myPointer: %@", self.myPointer) ;
  }
  </code></pre>
  
  <p>The point is that I still got the same answer I used to have:</p>
  
  <pre><code>2012-02-26 12:08:13.426 test1[1333:207] myString: (null)
  2012-02-26 12:08:13.427 test1[1333:207] myPointer: Hello world!
  </code></pre>