Blocks and nil termination compiler warnings


I am starting to really get into Objective-C (looking forward to I recently ported Underscore.js to Objective-C ( and had one problem that I couldn’t resolve…how to put up a compiler warning for nil termination on blocks.

Typically, Apple does something like this:

  • (id)arrayWithObjects:(id)firstObj, … NS_REQUIRES_NIL_TERMINATION;

but I need to do something like this:

  • (A*(^)(NSA* array, NSA* array1, … NS_REQUIRES_NIL_TERMINATION ))intersection; // (A is NSMutableArray, NSA is NSArray)

I played around with combinations of attribute((sentinel)) , but nothing produced the correct compiler-time warnings. Is there a way to do this now? Do I need to submit a request to a standards body? Is there already an implementation in the works? Questions, questions.

Also, I am looking for someone to help me optimize and push my port of Underscore.js in Objective.C (I’m nowhere near guru level to do thorough benchmarking and optimizations). If you are interested in pitching in, please let me know!


Sounds like another addition to . It looks like we don't support this attribute on types, only on declarations. It makes a lot of sense in my mind to sink the attribute down to the type.