Objective-C is a superset of C, and therefore anything C will work with them. However, std::vector
is a C++ class, which means the compiler has to be aware that you're going to use C, Objective-C and C++ code inside your program. You can do so by changing the extension of your source files from .m
to .mm
.
However, if you're still at the stage of learning Objective-C or C++, try to not mix too much C++ with it. C++ uses "non-POD types" (POD being "plain old data"), which are inherently incompatible with functions that take variadic arguments; under the hood, all Objective-C calls work that way, so that can make it complex to work with C++ types through Objective-C calls if you're not too sure about how it all works. You could use Cocoa's NSMutableArray
class too.