title: Swapping the values of two variables that point to objects
body: <p>I have the following problem, because i just have started coding objective-c. </p>
  
  <p>I have some instance with </p>
  
  <pre><code>@interface MyClass
      @property (strong) MySecondClass *first;
      @property (strong) MySecondClass *second;
  @end
  
  @implementation MyClass
      @synthesize first = _first;
      @synthesize second = _second;
  
      /*this is called while initialisation*/
      -(void) initialisation{
          _first = [[MySecondClass alloc] init];
          _second = [[MySecondClass alloc] init];
       }
  
      /*what i want to do*/
      -(void) swap{
          // second one should be replaced with first one
          _second = _first; 
  
          // first pointer should be replaced by new instance
          _first = [[MySecondClass alloc] init];
      }
  
  @end
  </code></pre>
  
  <p>Problem is, that when i call the swap method, the _first still points to the old object so _second will be replaced by same new object. </p>
  
  <p>I already tried copy like follows, but it throws an exception.</p>
  
  <pre><code> _second = [_first copy];
  </code></pre>
  
  <p>PS: Im using ARC</p>
  
  <p><strong>Edit</strong></p>
  
  <p>What i really would like to accomplish, would be something like: </p>
  
  <pre><code> _second = _first
   MySecondClass *tmp = [[MySecondClass alloc] init];
   _first = &amp;tmp;
  </code></pre>
  
  <p>But this shows compiler error:  Implicit conversion of an indirect pointer to an Objective-C pointer to 'MySecondClass *' is disallowed with ARC</p>
  
  <p>Thanks in advance.</p>