Search code examples
objective-cxcodecocos2d-iphonebox2dobjective-c++

Strange xcode errors using box2d


im using xcode4 and box2d/cocos2d.

Im having some strange difficulties with runtime errors that pop up 'randomly'.
I think they occur more when I dont stop the process before rebuilding/running.
Usually if i stop the process before i rebuild/run errors dont occur.

Sometimes I get an:

'NSInvalidArguementException', reason '-[ConstructLayer createCog:::]: unrecognized selector sent to instance 0x554ecd0.

Sometimes I get a strange error in a file called:

llvm:InstCombiner::DoOneIteration(llvm::Function&, unsigned int)_disassembly_0x026bc64f.nasm

with the line highlighted:

0x02bc64f <+0439> mov 0x20(%eax),%ecxn

And sometimes i get an error: malloc * error for object 0x68d4ba4: incorrect checksum for freed object - object was probably modified after being freed.

Here is my dealloc method:

- (void) dealloc{
delete world;
world = NULL;
body_block1 = NULL;
body_egg = NULL;
body_poly = NULL;

[_block1 release];
[_egg release];
[_poly release];
[super dealloc];
}

What on earth is happening? Usually errors happen 3 times in a row with different errors before it starts running again.
Help!
Thanks,
Oliver.


Solution

  • Try to Make an array nil after releasing it.

    [_block1 release];
    _block = nil;
    
    [_egg release];
    _egg = nil;
    
    [_poly release];
    _poly = nil;