title: segue: destination view controller weirdness
body: <p>In my app, I use a storyboard and segues, and I often pass data to the destination view controller before doing the segue, as follows:</p>
  
  <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
  {
      if ([segue.destinationViewController respondsToSelector:@selector(setMyData:)]) {
          [segue.destinationViewController performSelector:@selector(setMyData:) 
                                            withObject:myData];
      }
  } 
  </code></pre>
  
  <p>It works everywhere except in one place. The selector gets called, the data gets set, but when the segue completes and the destination controller appears, it doesn't have the data I just set. After printing the view controller's id in both the source and destination view controllers, I found that the <code>segue.destinationViewController</code> in the code above is a DIFFERENT instance of the view controller than the one that gets displayed. What's going on here?</p>
  
  <p><strong>[UPDATE 1]</strong>
  I looked into the lifecycle of the destination view controller, and it first gets loaded during the segue execution, but AFTER I set the property on it! This means, that when I call <code>performSelector</code> on it, the view controller object is not initialized! This is why the data I set doesn't stick. t don't understand why is this the case, and why this same approach works in the other parts of my app. </p>
  
  <p><strong>[UPDATE 2]</strong>
  Posting the code of <code>setMyData</code> by request. At first I didn't have this method at all, because <code>locationToOpen</code> is a public property. I only added it to ensure it gets called and to print the debug info.</p>
  
  <pre><code>- (void)setMyData:(MyData *)myData
  {
      DLog(@"self: %@", (id)self);
      _myData = myData;
  }
  </code></pre>