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