title: iOS handle didSelectRowAtIndexPath in custom class
body: <p>I've seen a way how to set handler for events in custom classes. Something like this:</p>
  
  <pre><code>@implementation CustomClassWithTable {
      void (^_cellHandler)(Cell *cell);
  }
  
  ...
  
  - (void)setCellHandler:(void (^)(Cell *))handler
  {
      _cellHandler = handler;
  }
  
  ...
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      ... 
      if (_cellHandler) {
          _cellHandler(cell);
      }
  }
  </code></pre>
  
  <p>then in controller it just need to set cellHandler and it works. I like it. First of all what is name of this aproach (pattern)? Second how can I do this in swift? And is it the best aproach? Lets say I have table in my custom class (menu) and I want to be able get selected cell in my view controller. Should I use this aproach or something else (delegate pattern for example)? </p>