title: NSComparator in Separate File
body: <p>I have a sorting comparator which I need to use in a few different ViewControllers so I'm trying to keep it in a separate file. I've read I should be able to put the sorting block in a separate file, but which ever method I try I seem to get "unrecognized selector sent to instance". The code I have is:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  typedef NSComparator (^IntBlock)(id obj1, id obj2);
  
  @interface Utils : NSObject {
      NSComparator SortObjNameComparer;
      NSComparator SortObjPriceComparer;
  }
  @property (readwrite, copy) NSComparator SortObjNameComparer;
  @property (readwrite, copy) NSComparator SortObjPriceComparer;
  </code></pre>
  
  <p>To sort this I'm using</p>
  
  <pre><code>Utils *comp = [[Utils alloc] init];
  if(segmentedControl.selectedSegmentIndex == 0){
      self.productArray = [self.productArray sortedArrayUsingComparator:[comp SortObjNameComparer] context:nil];   //EXC_BAD_ACCESS     
  } else if(segmentedControl.selectedSegmentIndex == 1){
      self.productArray = [self.productArray sortedArrayUsingComparator:[Utils SortObjPriceComparer]];// EXC_BAD_ACCESS
  </code></pre>
  
  <p>Is there a clean way to do this?</p>