title: Only perform selector if target supports it?
body: <p>How do you call optional protocol methods?</p>
  
  <pre><code>@protocol Foo
  @optional
  - (void) doA;
  - (void) doB;
  @end
  </code></pre>
  
  <p>Now we have to check each time we want to call <code>doA</code> or <code>doB</code>:</p>
  
  <pre><code>if ([delegate respondsToSelector:@selector(doA)])
      [delegate performSelector:@selector(doA)];
  </code></pre>
  
  <p>That’s just silly. I’ve come up with a category on <code>NSObject</code> that adds:</p>
  
  <pre><code>- (void) performSelectorIfSupported: (SEL) selector
  {
      if ([self respondsToSelector:selector])
          [self performSelector:selector];
  }
  </code></pre>
  
  <p>…which is not that much better. Do you have a smarter solution, or do you just put up with the conditionals before each call?</p>