title: Did the Target-Action design pattern became bad practice under ARC?
body: <p>For years I've been following a great pattern called Target-Action which goes like this:</p>
  
  <p>An object calls a specified selector on a specified target object when the time comes to call. This is very useful in lots of different cases where you need a simple callback to an arbitrary method.</p>
  
  <p>Here's an example:</p>
  
  <pre><code>- (void)itemLoaded {
      [specifiedReceiver performSelector:specifiedSelector];
  }
  </code></pre>
  
  <p>Under ARC it now turns out that doing something like this all of a sudden became dangerous.</p>
  
  <p>Xcode throws a warning that goes like this:</p>
  
  <blockquote>
    <p>PerformSelector may cause a leak because its selector is unknown</p>
  </blockquote>
  
  <p>Of course the selector is unknown since as part of the Target-Action design pattern you can specify whatever selector you want in order to get a call when something interesting happens.</p>
  
  <p>What bugs me most about this warning is that it says there can be a potential memory leak. From my understanding ARC doesn't bend the memory management rules but instead simply automates the insertion of retain/release/autorelease messages at the right locations.</p>
  
  <p>Another thing to note here: -performSelector: does have an <code>id</code> return value. ARC analyzes method signatures to figure out through application of naming conventions if the method returns a +1 retain count object or not. In this case ARC doesn't know if the selector is a <code>-newFooBar</code> factory or simply calling an unsuspicious worker method (which is almost always the case with Target-Action anyways). Actually ARC should have recognized that I don't expect a return value, and therefore forget about any potential +1 retain counted return value. Looking at it from that point of view I can see where ARC is coming from, but still there is too much uncertainty about what this really means in practice. </p>
  
  <p>Does that now mean under ARC something can go wrong which would never happen without ARC? I don't see how this could produce a memory leak. Can someone give examples of situations in which this is dangerous to do, and how exactly a leak is created in that case?</p>
  
  <p>I really googled the hell out of the internet but didn't find any site explaining <em>why</em>.</p>