Do I have to get rid of my release statements upon upgrading to ARC?

Deadly 提交于 2019-12-11 15:02:20

问题


New to all this ARC stuff.

I've been developing an iOS game using Manual Reference Counting with cocos2d-iphone 1.0.1 this whole time.

Recently, upon reading some instructions (http://www.tinytimgames.com/2011/07/22/cocos2d-and-arc/#comment-563567859), I upgraded my project to support Automatic Reference Counting.

When I developed using the manual method, I, of course, used release in many places. However, I noticed that I had many memory leaks and I was having a hard time finding all of them - thus I changed to ARC.

However, I wonder, do I have to erase my [object release]; statements for ARC to work properly? Or it doesn't matter and I really don't have to do any kind of change at all?

If I used [object retain]; and [object release];, do I get rid of the former and assume that ARC will take care of releasing it? Or do I still have the responsibility of releasing manually it since I explicitly took ownership of the object?


回答1:


NO need to manually do all these stuffs.

You should refactor your code. Check here How to Refactor to ARC.

Also How do I convert my Xcode project to use ARC (Automatic Reference Counting)?




回答2:


Calling retain or release is an error when you're using ARC, it won't even compile.



来源:https://stackoverflow.com/questions/15170655/do-i-have-to-get-rid-of-my-release-statements-upon-upgrading-to-arc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!