One: @property properties for various data types
A. Memory management nsstring:copy Basic data types, structs (int, cgfloat, BOOL, CGRect, etc.): Assign objects such as custom model types, Nsarray, Nsdictionary): Strong control: Weak other details: Atomic and nonatomicatomic mean setter/getter This function is a primitive operation. If more than one thread calls the setter at the same time, one thread does not appear before the entire setter statement, and the other thread starts executing the setter condition, which is equivalent to the function's end and end lock. Nonatomic does not guarantee the setter/getter of the original line, so you may be able to take something incomplete. For example, the setter function changes two member variables, if you use Nonatomic, the getter may be taken to change only one of the variables when the state, so that the problem of what to take. If you do not need multi-threading support, of course, nonatomic is sufficient, and because it does not involve the lock operation, so it does relatively fast atomic: The default is the property, this property is to ensure that the program in multithreaded situations, the compiler will automatically generate some mutex lock code, Avoid read and write synchronization of this variable. Nonatomic: If the object does not need to consider multithreading, add this property, which will allow the compiler to generate a few mutually exclusive lock code, can improve efficiency. ReadWrite and Readonlyreadwrite: This property is the default and will automatically generate accessors for you. ReadOnly: Only getter Generation does not have setter methods. The real value of the two properties of ReadWrite, ReadOnly, is not to provide a member variable access interface, but to control access to member variables. Strong and Weakstrong: Strong references, which we usually refer to, determine the survival of the object directly. If there is no reference to an object and the object no longer appears in the list, the object is freed from memory. Weak: Weak references do not determine the survival of an object. Even if an object is held with countless weak references, it is cleared if no strong references point to it. Pointer set to Nil;strong and retain function similar, weak and assign similar, only when the object disappears weak will automatically change the pointer to Nil;assign, copy, retainassign: Default type, setter method directly assigned value, Do not perform any retain operations without changing the reference count. Typically used to handle basic data types. Retain: Releases the old object (release), and the old object'sValue is assigned to the new object, and the new object reference count is 1. I understand that as a copy of the pointer, copy the original pointer, release the contents of the object pointed to by the original pointer, and then point the pointer to the new object content. Copy: As with the retain process, release the old value first, and then copy the new object, Retaincount to 1. The mechanism introduced to reduce dependency on the context. I understand a copy of the content, request a piece of space into memory, assign the original object content to it, and make its reference count 1. Pay special attention to the Copy property: the object defined with the Copy property must conform to the Nscopying protocol and must implement the-(ID) Copywithzone: (Nszone *) Zone method. can also be used directly:
iOS Development knowledge fragment----