问题
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