First, Basic introduction
Øarc is a new feature that has been 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
Ø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 pointers and weak pointers
Ø default All instance variables and local variables are strong pointers
Ø the weak pointer automatically becomes a nil pointer when the object pointed by the weak pointer is reclaimed, and does not throw a wild pointer error
Third, the use of attention
Ø cannot call release, retain, Autorelease, Retaincount
Ø can rewrite Dealloc, but cannot call [Superdealloc]
Ø @property: Want to have an object for a long time, should use strong, other objects with weak
Ø Other basic data types are still used assign
Ø at both ends of the reference, one end with strong, one end with weak
Dark Horse programmer -19-oc about ARC