开发者

memory management in objective-c for retain

HI i have questions on Memory 开发者_如何学PythonManagement If I alloc object 1 time then i retain 2 time And then release 4 time & then retain 1 time for same object. what will be my final ans?


Crrrrraaassshh!


The object will be dealloced after the third release (when the retainCount hits zero) and the fourth release will be sent to a non-valid object, resulting in a crash.

If you want an object to exist for a little while after you've released it, you should look into the autorelease method.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜