I need to be able to add and remove an arbitrary number of points to an array. In C++ I could do this easily using vector which allows me to add and remove items of any type.
I know I could store structs in an NSMutableArray using the NSValue class, but I would prefer a faster method than creating and destroy NSValue objects constantly. Is there something similar to the vector class in Objective-C or is there another way to add and remove my structs to arrays (I would prefer not to use Objective C++)? Or am I stuck with NSMutableArray and NSValue.
EDIT: NSMutableData seems like a possible solution.
If you were not targetting iOS, I would suggest
NSPointerArray, which obviates the necessity of wrapping your rawstructdatatypes inNSValuecontainers. However, this class is (unfortunately) not available on iOS.Apple acknowledge this in their
NSArraydocumentation for iOS, under the title Alternatives to Subclassing.In other words, you can indirectly create an
NSArray(or mutable counterpart) that directly holds your non-object datatypes.