title: Implementing the Target-Action Design Pattern in Objective-C
body: <p>I'm trying to implement the Target-Action Design Pattern in a custom class. The interface will have the following method:</p>
  
  <pre><code>- (void)addTarget:(id)target action:(SEL)action forEvents:(MyEvents)events;
  </code></pre>
  
  <p>MyEvents is a NSUInteger. What's the best way to store these informations on my class? Opening the file UIControl.h I noticed that UIKit contains the following:</p>
  
  <pre><code>NSMutableArray* _targetActions;
  </code></pre>
  
  <p>I suppose that all actions are added in this array encapsulated in an NSObject (do I need to create another custom object or is there something I can reuse?) and every time it needs to perform an action it iterates the array using the bitmask as a filter. Is it correct?</p>
  
  <p>Thanks in advance.</p>