Internal principles of Arc in iOS

Source: Internet
Author: User

As you already know, ARC will automatically help you insert retain and release statements. The arc compiler has two parts, the front-end compiler and the optimizer respectively. 1. Front-End compilers

The front-end compiler inserts the corresponding release statement for each of the "owned" objects. If an object's ownership modifier is __strong, then it is owned. If an object is created within a method, the front-end compiler automatically inserts a release statement at the end of the method to destroy it. Objects owned by a class (instance variables/properties) are freed within the Dealloc method. In fact, you don't need to write dealloc methods or invoke the Dealloc method of the parent class, and arc will automatically help you accomplish everything. In addition, the code generated by the compiler is even better than the performance of your own release statement, because the editor can make some assumptions. In Arc, no class can overwrite the release method or call it necessary. Arc optimizes the calling process by directly using Objc_release. And for retain is the same way. ARC invokes Objc_retain to replace the reserved message. 2. Arc Optimizer

Although the front-end compiler sounds very powerful, there are sometimes several repeated calls to retain and release in the code. The Arc Optimizer is responsible for removing redundant retain and release statements, ensuring that the generated code runs faster than the manual reference count code.

In the 28th chapter you'll see more about how arc works inside.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.