I am building an app targeting the iPhone. I need to maintain a group of entities. The group grows dynamically.

Historically I have used an STL vector. It grows automatically and performs well. But now I am moving more and more to cocoa and obj-c. In particular, I am using archiving feature of NSCoding. So I have an objective-c based object that represents my level.

I need to store a group of entities. Each entity is often just a c-struct (I am using chipmunk physics.)

Unfortunately, embedding an stl vector as an instance variable in my obj-c class generates warnings about not calling constructors and destructors. I have tried using a pointer to a vector, and manually constructing and destructing, but I seem to be having some issues - especially during encoding and decoding.

NSArray seems to only be for storing obj-c objects.

So my question is:
Should I continue trying to use a c++ stl vector as an instance variable, or is it better to fallback to old school c-arrays? I hesitate allocating big arrays with wasted space, but that might just be the easiest thing to do.

You can make the Obj-C++ thing work. -fobjc-call-cxx-cdtors may help (see "man gcc" for details), or you can use "placement new" to call the objects' constructors yourself, or you can use a pointer-to-c++-object member, and use new and delete to manage it explicitly.

Obviously NSArray is going to be by far the easiest. All you need to do is wrap that Entity in an NSObject subclass and you get all the happiness that NSArray provides.

The only reason for not using it really is if you can't afford the performance overhead. In that case you can always realloc to deal with dynamic sized c arrays, or like you said just waste memory. At least that way you know your limits and won't accidentally run out of memory on an iPhone

I've been down this route many times ( not on the iPhone, admittedly ). You'll probably find it easiest to define an ObjC class which encapsulates the chipmunk physics struct, and which has an accessor for that struct. 1 minute of work, and you don't need to worry any more.