How to properly allocate and deallocate box2d objects in cocos2d, iOS

Viewed 1414

I wonder what is the best way to allocate and deallocate box2d objects (b2World and b2Body) in cocos2d for iOS?

Allocate

@property (nonatomic, assign) b2World * world;
@property (nonatomic, assign) b2Body * body;

Deallocate

-(void)dealloc {
      delete _world;
      _world = nil;
      _body = nil;

Can somebody explain why I can not use retain and release for b2World and b2Body and why do we use delete _world in dealloc method? Why do we not delete body objects also? (delete _body doesnt work). When setting pointers to nil: should I use nil or NULL?

1 Answers
Related