[Cocos2d 2.x iOS development NOTE 2] Enable arc in the project

Source: Internet
Author: User

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!]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.