Reputation: 1649
i'm currently rewriting an app, and i can't explain myself this bug :
I've a class "Player" with an NSMutableArray named "pieces". When I remove from this array the last "Piece" object of my first player (i've got two and this bug occurs only with the first one), the Player object is dealloc'd.
If you have any idea for this bug... I'm still here if you need any piece of code to understand...
Upvotes: 1
Views: 89
Reputation: 9113
That's because owner property is probably implemented as retain property.
So pieces own a reference to player and player is not dealloc until your last piece is released. You probably release your player where you shouldn't and retain it where you shouldn't as well (in piece object).
Replace the owner property with (nonatomic, assign) and track the place where you release the player.
Upvotes: 2