1 . MRCin objective-c language (mannulreference counting)
in MRC retain,release and autorelease retain and release nsautoreleasepool object, To join the auto-release pool ( autorelease Called), when drain When the memory is reclaimed.
(1)retain, the function of this method is to attach the ownership of the memory data to another pointer variable, the reference number plus 1, namely retaincount+= 1;
(2)Release, the method is to release the pointer variable to the memory data ownership, the reference number minus 1, that is retaincount-= 1;
(3)autorelease, the method is to put the object memory management into autoreleasepool .
2. ARCinobjective-c language (automaticreference counting )
Memory management-related identifiers in ARC can be divided into variable identifiers and attribute identifiers, __strong for variables , __weak by default , strong and for attribute table have:
@property (nonatomic/atomic,assign/retain/strong/weak/unsafe_unretained/copy,readonly/readwrite) Number* num;// default is unsafe_unretained .
There are also Autoreleasepool.
the ARC management mechanisms that are required for the Core Foundation to be exchanged with objective-cobject are:
(1) (__bridge_transfer<nstype>) op oralternatively cfbridgingrelease (OP) isused to consume a retain-count of a CFTyp Eref whiletransferring it over to ARC. This could also is represented by id someobj = (__bridge <NSType>) op; Cfrelease (OP);
(2) (__bridge_retained<cftype>) op oralternatively cfbridgingretain (OP) isused to hand an nsobject Overto CF-land wh Ile giving it a +1 retain count. You should handle a cftyperefyoucreate this is the same as you would handle a result of cfstringcreatecopy (). This could also is represented by Cfretain ((__bridge cftype) op); Cftyperef sometyperef = (__bridge cftype) op;
(3) __bridge justcasts between Pointer-land and Objective-c Object-land. If you had noinclination to use the conversions above.
The MRC and ARC memory management mechanisms of the
OC Note: Xcode4 did not previously have arc.