ARC is not used for newly created projects using cocos2d 2.x. Therefore, to save the manual memory management, it is necessary to use arc to improve coding efficiency.CodeArc conversion.
After reading some tutorials, some of them are very difficult to write. Later I found that arc conversion is too easy, as long as I use the conversion tool that comes with xcode, it can be easily solved. Let's go!
Step 1: Open the project and select edit-> refactor-> convert to objective-C arc...
Step 2: select the last four files and click check as follows:
Step 3: Check if there is no problem. The following window appears. Click next:
Step 4: display the review changes after arc conversion. No problem. Click Save.
At this time, the system will prompt whether to save the snapshot backup:
Select as needed. If it is a newly created Project, disable it.
After the above steps, the conversion of arc is complete. Very easy.
The above is the automatic conversion method, or you can manually convert it. here we will learn about the method:
Step 1:
As shown above, find build phases in xcode and compile files. The result of arc conversion is displayed. During the conversion, only the files to be edited at the top layer are converted, we didn't use arc for the cocos2d library file. here we can see that it is actually adding a compilation flag on the file:-fno-objc-arc, indicating that arc compilation is not used.
Step 2:
Then, find the above options in building settings. You can find them by searching for the keyword 'arc '.
Here, objective-C automatic reference counting is yes, indicating that arc is used. This is also the result of conversion. If it is manually modified, it is OK to change no to yes.
The above is all the content for enabling arc.
[Note: This article is originalArticle, All rights reserved. If you need to reprint it, please indicate the source! Thank you!]