ARC(Automatic Reference Counting) is a new feature in iOS 5. In simple terms, retain/release is automatically added to the code, and the code that needed to be added manually to handle reference counting for memory management is automatically done by the compiler. For one thing, ARC is not GC, it is just a Static Analyzer tool for code analysis. #####assign: retain the Reference Counting function #####retain: retain: retain: #####Copy: retain does not contain the same object. Retain does not contain the same object. For example, an NSString whose address is 0×1111 and contents are @ “t-bag” is copied to another NSString whose address is 0×2222 and contents are the same, the new object will retain 1 and the old object will remain unchanged. Retain = retain +1; retain = copy = copy; retain = copy The old objects are released before being copied.

#####readonly: indicates that this property is read-only, that is, only getters are generated, but not setters. ##### readWrite: Set the available access levels #####retain, copy, and assign

  1. Suppose you allocate a block of memory using malloc and assign its address to pointer A. Then you assign a to POINTER B because you want pointer B to share this block of memory. In this case, a and B point to the same block of memory. When A no longer needs this block of memory, can it be released directly? The answer is no, because A does not know whether B is still using the memory block. If A frees the memory block, b will cause the program to crash when using the memory block.
  2. Given the problem of assign in 1, how to solve it? The simplest way to do this is to use reference counting. In the same example above, we assign a reference count to that block of memory. When memory is allocated and assigned to A, the reference count is 1. The reference count increases to 2 when a is assigned to b. If A is no longer using the memory, it simply subtracts the reference count by one to indicate that it no longer owns the memory. B also decreases the reference count by one when it no longer uses the memory block. When the reference count goes to 0, the memory is no longer referenced by any Pointers, and the system can simply free it.
  3. Retain (retain) : retain (float) : retain (float) : retain (float) : retain (float) : retain (float) : retain (float) : retain (float) Retain uses a reference count, as described in 2. Retain causes the reference count to increase by 1 and release causes the reference count to decrease by 1. When the reference count reaches 0, the dealloc function is called and memory is reclaimed.
  4. Copy is used when you don’t want a and B to share a piece of memory. A and B each have their own memory.
  5. Atomic and nonatomic are used to determine whether getters and setters generated by the compiler are atomic operations. In a multithreaded environment, atomic manipulation is necessary, otherwise incorrect results may be caused.