views:

124

answers:

2

Is there a nice way to do this in Objective-C, or do I have to write my own tedious logic?

I'm creating and destroying a little of little state objects per frame in an iPhone game. It would be nice if I could just reuse objects from a pool.

+1  A: 

Neither Cocoa nor Objective-C does anything particularly helpful for object pools. They don't do anything to stop you either, but you'll basically have to DIY.

Chuck
What about creating a memory zone? Am I mistaken in thinking that this works as a sort of pool?
Ranking Stackingblocks
They can be useful in this situation, but they're very distinct from object pools, at least as I understand them. Memory zones can conceivably make allocation more efficient and help keep related objects contiguous, but you still allocate and deallocate as normal inside them.
Chuck