MRC and ARC Hybrid Development configuration

Source: Internet
Author: User

After iOS4.1, the ARC mode is the default, and arc is essentially implemented with compiler features, which can be implemented simply by modifying the file configuration.

1. To switch to MRC you need to select the current project, choose Build Settings, type Auto in the query box, find Objective-c Automatic Reference counting, and select Yes to No. See:

2. You can also flexibly select single or several files to be set to ARC mode, by selecting targets, finding compile Sources, selecting the desired file, flags, typing-FOBJC-ARC. See:

3. You can also flexibly select single or several files to be set to MRC mode by selecting targets, finding compile Sources, selecting the desired file, flags, typing-FNO-OBJC-ARC. See:

Memory management principles: 1 who Created (Alloc,new), who release or autorelease;2) who retain,mutablecopy (copy), who release or autorelease; MRC: Manual memory management When new objects appear, manually add release or Autorelease. ARC Works: Arc is a feature of the Objective-c compiler, not a runtime feature or garbage collection mechanism, and arc does nothing but automatically insert release or autorelease at the appropriate location for you when the code is compiled. ARC's judging criteria: as long as there is a strong pointer variable pointing to the object, the object remains in memory. As long as no strong pointer points to the object, the object is freed. Note: When using arc, temporarily forget "reference counter" because the judging criteria has changed

MRC and ARC Hybrid Development configuration

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.