title: Event + Handler
body: <p>How can I create same action like have UIButton or other UI controllers?</p>
  
  <pre><code>UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  [button addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
  [view addSubview:button];
  
  ...
  
  - (void)buttonClicked
  {
  // Handler
  }
  </code></pre>
  
  <p>I would like to have a class which can call a custom handler. How can I create this class and how can I add a custom handler? (I would like same idea with buttonClicked.)</p>
  
  <hr>
  
  <p>Chuck, that's exactly what i asked! Thank you! One more things, how can i send one argument to my action. I would like have one NSString parameter in my handler</p>
  
  <p>I would like something like this (but it's not work):</p>
  
  <pre><code>@interface Example : NSObject {
      id target;
      SEL action;
  }
  
  - (id)initWithTarget:(id)targetObject action:(SEL)runAction;
  - (void)activate;
  @end
  
  @implementation Example
  - (id)initWithTarget:(id)targetObject action:(SEL)runAction {
      if (self = [super init]) {
          target = targetObject;
          action = runAction;
      }
      return self;
  }
  
  - (void)activate {
      [target performSelector:action withObject:self withObject: @"My Message"];
  }
  @end
  
  @interface ExampleHandler : NSObject {
  
  }
  
  -(void):init;
  -(void)myHandler:(NSString *)str;
  
  @end
  
  @implementation ExampleHandler
  
  -(void)init {
      [super init];
      Example *ex = [[Example alloc] initWithTarget: self action: @selector(myHandler) ];
  
  }
  
  -(void)myHandler:(NSString *)str {
      NSLog(str);
  }
  
  @end
  </code></pre>