I am starting to really get into Objective-C (looking forward to http://clang.llvm.org/docs/ObjectiveCLiterals.html). I recently ported Underscore.js to Objective-C (https://github.com/kmalakoff/_.m) 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!