NSArray -s cannot store id objects. You must insert it into NSNumber :
NSUInteger i; for (i=0;i<5;i++) { [array addObject:[NSNumber numberWithUnsignedInteger:i]]; }
either use CFArray with custom callbacks (but you sacrifice readability for performance) or use std::vector<NSUInteger> (but you need to use Objective-C ++).
source share