Dark Horse programmer -19-oc about ARC

Source: Internet
Author: User

First, Basic introduction

Øarc is a new feature that has been added since iOS 5, completely eliminating the cumbersome manual management of memory, and the compiler will automatically insert appropriate retain, release, autorelease statements where appropriate. You no longer need to worry about memory management, because the compiler handles everything for you

Øarc is a compiler attribute, not an IOS runtime feature, nor is it similar to a garbage collector in other languages. So ARC and manual memory management performance is the same, and sometimes faster, because the compiler can also perform some optimizations

Second, the basic principle 1. Rules

The rules of ARC are very simple: as long as there is a strong pointer variable pointing to the object, the object remains in memory

2. Strong pointers and weak pointers

Ø default All instance variables and local variables are strong pointers

Ø the weak pointer automatically becomes a nil pointer when the object pointed by the weak pointer is reclaimed, and does not throw a wild pointer error

Third, the use of attention

Ø cannot call release, retain, Autorelease, Retaincount

Ø can rewrite Dealloc, but cannot call [Superdealloc]

Ø @property: Want to have an object for a long time, should use strong, other objects with weak

Ø Other basic data types are still used assign

Ø at both ends of the reference, one end with strong, one end with weak

Dark Horse programmer -19-oc about ARC

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.