Application of Arc

Source: Internet
Author: User
First, Basic introduction

1> arc is a new feature 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 .

2>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 pointer and if pointer:

The default all instance and local variables are strong pointers.

When an object pointed to by a weak pointer is reclaimed, the weak pointer automatically becomes a nil Pointer and does not throw a wild pointer error.

Third, the use of attention

1> cannot call release, retain, Autorelease, Retaincount.

2> can override Dealloc, but cannot invoke [super Dealloc].

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

4> other basic data types still use assign.

5> both ends of the reference, one end with strong, one end with weak.

Application of 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.