ios-How to convert a non-ARC project into an arc project (actual combat)

Source: Internet
Author: User

1. PrefaceBecause the company has a foreign catering system, programming and development for 3-4 years, before the use of all non-arc, development to this year, the first batch of iterative development of the personnel has been missing, and now found that there is a lot of memory leaks, the system does not automatically release the freed memory. Once the app has been in use for a long time, memory is not released and the app is eventually blown. It involves a lot of places, especially complicated. Therefore, I have the intention to fully convert this project to the ARC project. After 1 weeks of conversion and 1 weeks of testing, the non-ARC project was successfully converted to the ARC project. There is very little information on the web because there are few companies that can convert large old apps into arcs. After this attempt, I proved that it was feasible. Let's summarize some of the problems I've encountered in the blog. After all, arc is the OBJC future. Xcode comes with an auto-convert feature, but it's only suitable for smaller projects and is not suitable for large projects, so I'm here for full manual conversions.2. Change the project compilation environment to ARC

Change the red circle from No to Yes

If your current project does not support arc technology, you can use an automatic conversion tool to convert your project (tools at Edit>refactor>convertto objective-c ARC), this tool automatically converts the points in the manual management of all projects into the appropriate automatic mode (such as removing retain, release, etc.). This tool will convert all the files in the project. Of course you can convert individual files.3. The following functions: Dealloc,retain, Release, Retaincount, Autorelease. Prohibit any form of invocation and implementation (Dealloc may be implemented)

Erase or annotate all these memory-management things

4. You cannot use nsautoreleasepool. You can consider direct annotations

As an alternative, @autoreleasepool is introduced and you can use this more efficient keyword.

5. Do bridging conversion times wrong, replace with Xcode hint

some rules of 6.ARC syntax

6.1. Retain, release, retain, Autorelease are not available in the code

6.2. Do not overload the Dealloc (the function can be overloaded if it is disposed of outside the object's memory, but cannot be called [Super Dealloc])

6.3. Cannot use Nsallocateobject, Nsdeallocateobject

6.4. Object pointers cannot be used in C struct bodies

Between 6.5.id and void * If cast requires a specific method (__bridge keyword)

6.6. Cannot use NSAutoreleasePool, but need @autoreleasepool block

6.7. The name of the property that cannot be started with "new" (if used there will be a compile error below "Properties ' s synthesized getter follows COCOA naming convention for returning ' owned ' O Bjects ")

7. Third-party package issues, third-party framework issuesMany third-party frameworks may be referenced in our project. Most of them use macros to allow the code to adapt to both arc and non-arc(with # if __has_feature (OBJC_ARC))。 If you have a small amount of code, consider rewriting it yourself. You can manually rename the third-party frame yourself to arc if it is a large frame, you can take this framework to keep the non-arc environment intact and continue to use it.1, select the targets in the project, select the target you want to manipulate ,
2, choose Build phases, in which Complie sources select the file that needs arc double-click, and enter in the input box:-FOBJC-ARC, if not arc input:-fno-objc-arc Clear Saup
Source: http://www.cnblogs.com/qingche/
This article is copyright to the author and the blog Park is shared, welcome reprint, but must retain this paragraph statement, and in the article page obvious location to give the original text connection.

ios-How to convert a non-ARC project into an arc project (actual combat)

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.