Strong and weak are new object variable attributes introduced by ARC. The weak and strong attributes are required only when you open the ARC.
@ Strong is similar to @ retain
@ Weak is similar to @ assign, but @ weak has assigned a value to nil after it is released. The advantage of this operation is to prevent the disturbance of the wild pointer, which is known to all users.
@ Copy this attribute is only valid for object types that implement the NSCopying protocol. As the meaning of deep copy, the new memory space is opened up, and the content is copied into the memory. In this way, there are two objects which are irrelevant.
@ Retain: Add 1 to the reference count and point the pointer to an existing memory address. In this way, the pointer from retain points to the same address as the original address, increasing the reference count, the actual memory address only contains one copy of data. Reference COUNTING METHOD
In a simple sentence, @ copy deep copy @ retain shallow copy
@ Assign: simple assignment without changing the index count
Applicable to basic data types (such as NSInteger and CGFloat) and C data types (int, float, double, char, etc. In particular, the delegate attribute in Objective-c must be set to @ assign (@ weak for iOS5) to prevent memory leakage caused by memory failure due to cyclic reference.
For example, if you use malloc to allocate a piece of memory and assign its address to pointer a, then you want pointer B to share the block of memory, so you assigned a to (assign) B again. In this case, a and B point to the same memory. A no longer needs this memory. Can it be released directly. If it is the @ retain attribute, the memory is managed by referencing the count method. When the reference count is 0, the memory is released, and @ assign cannot be used to release a directly, because I don't know if B is still using something in the memory, it's extremely dangerous.
@ Readonly: Read-only attribute. If you use the @ synthesize keyword, the reader method (get) is parsed. And if you try to assign values to attributes using the vertex operator, you will get a compilation error.
@ Readwrite indicates that the attribute is read/write, which is also the default attribute.
_ Weak, _ strong is used to modify the variable, and _ unsafe_unretained and _ autoreleasing are used to modify the variable.
_ Strong is the default keyword.
_ Weak declares a weak reference that can be automatically nil.
_ Unsafe_unretained declares a weak application, but it will not be automatically nil. That is to say, if the memory area to which it is directed is released, this pointer is a wild pointer.
_ Autoreleasing is used to modify a function parameter, which is automatically released when the function returns.