title: How do you store a function pointer in an ObjectiveC class?
body: <p>Some of Apple's <em>obj-c</em> API's still use C functions, e.g.:</p>
  
  <blockquote>
    <p>-(NSArray * ) sortedArrayUsingFunction: (NSInteger (*)(id, id, void *))comparator
    context:(void *)context</p>
  </blockquote>
  
  <p>...which is great, except I'm struggling to see how you can store fn-pointers inside ObjC classes.</p>
  
  <p>e.g. to share the same "sort" function in different parts of your program. Say you have different data, in different contexts/classes, but you want the same sort in both places (for consistency).</p>
  
  <p>I'm sure this is simple, but either my C is too rusty, or there's some gotcha. I tried sticking a plain variable inside the header file:</p>
  
  <blockquote>
    <p>NSInteger (*)(id, id, void *) myComparator;</p>
  </blockquote>
  
  <p>...and all I get is a compiler error:</p>
  
  <blockquote>
    <p>Expected identifier or '(' before ')' token</p>
  </blockquote>