First, Basic introduction
1> arc is a new feature 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 .
2>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 pointer and if pointer:
The default all instance and local variables are strong pointers.
When an object pointed to by a weak pointer is reclaimed, the weak pointer automatically becomes a nil Pointer and does not throw a wild pointer error.
Third, the use of attention
1> cannot call release, retain, Autorelease, Retaincount.
2> can override Dealloc, but cannot invoke [super Dealloc].
3> @property: Want to have an object for a long time, should use strong, other objects with weak.
4> other basic data types still use assign.
5> both ends of the reference, one end with strong, one end with weak.
Application of Arc