Is there a good way to convert a vector<int32_t>
to an NSArray
of NSNumber
or is looping and adding to an NSMutableArray
pretty much the only way?
If you have a vector of objects, you can do the following:
NSArray *myArray = [NSArray arrayWithObjects:&vector[0] count:vector.size()];
However, if your vector contains primitive types, such as NSInteger
, int
, float
, etc., you would have to manually loop the values in the vector and convert them to a NSNumber
first.