The role of the "iOS series"-autorelease

Source: Internet
Author: User

Memory management principles (pairing principle): As long as the New,alloc,retain method appears, pairing appears Release,autorelease 1: object is deposited into the auto-release pool, When the pool is destroyed, he will perform a release operation on all objects in the pool. 2:autorelease several times, it will be released several times.3: Regardless of whether you created the object in @autoreleasepool or created outside, as long as you call the autorelease in the pool, then this object will be put into the pool4:autorelease Scope: Is the end of the code block.
@autoreleasepool {         }  
ARC Mechanism: ARC, no programmer is going to manage memory 1. Strong pointer strong: As long as there is a strong pointer to an object, the system does not reclaim the object 2. Weak pointer weak: As long as there is no strong pointer to the object, the system immediately reclaims the object,-the weak pointer does not affect, the object is recycled//By default , all pointers are strong pointer type//ARC mechanism strong object, manual memory management retain keyword, (must be able to be applied on object type variable)//ARC mechanism weak object Manual memory management assign keyword, ( Must be able to be applied on object type variables) The @property parameter of the basic data type under the//ARC mechanism is fully consistent with manual memory management
@property (nonatomic,assign) int age; When a class loop is applied, it is only possible to change the strong reference on one hand to weak and to notify the existence of the. h file class by using the @class class name in the. h file. attached:1: Arc and non-arc coexistence in Project: in Project-->targets-->build phases-->compile sources Select to add parameters to non-ARC code (double-click):
-fno-objc-arc

2: Change the project to non-arc

Project-->targets-->build settings-->applellvm6.0-language-objective C

or enter language in the input box to find more convenient

Darren

Weibo: @IT_ Siege Division

GitHub: @Darren90

Source: http://www.cnblogs.com/fengtengfei/

The role of the "iOS series"-autorelease

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.