开发者

Object released without my consent

开发者 https://www.devze.com 2023-02-01 02:46 出处:网络
i\'m currently rewriting an app, and i can\'t explain myself this bug : I\'ve a class \"Player\" with an N开发者_开发技巧SMutableArray named \"pieces\".

i'm currently rewriting an app, and i can't explain myself this bug :

I've a class "Player" with an N开发者_开发技巧SMutableArray 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...


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号