[IOS] arc rules

Source: Internet
Author: User

The background and concepts of the Arc are not described in detail. In short, when using the arc, programmers do not need to care about the object's lifecycle. the compiler will cleverly Add the code during compilation.

Use arc rules:

1. You cannot call methods such as retain, release, auto-relase, and retain count of an object, or indirectly call methods similar to @ selector (retain.

2. The dealloc method of the object cannot be called.
Although the dealloc method of the redefinition class is allowed, the dealloc method of [Super dealloc] or any member variable cannot be called in it, and only some aftercare work is allowed, for example, release some file resources.

3. In the @ property declaration, keywords such as retain, copy, and assign are no longer allowed. They are replaced by two new keywords: strong and weak.

4. When the structure contains object pointers, it is best not to use struct, instead of class, because arc may not be able to recognize the object pointers in struct.

5. You are not allowed to use the NSAID utoreleasepool object. Instead, the @ autoreleasepool {} block is replaced. For example:

Int main (INT argc, char * argv []) {@ autoreleasepool {return uiapplicationmain (argc, argv, nil, nsstringfromclass ([myappdelegate class]);
}}

6. nszone is not allowed to apply for memory space. Nsallocateobject and nsdeallocateobject are not allowed.

 

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.