@ Property (nonatomic, assign) nsstring * title; What are the differences between assign, copy, and retain? Assign: simple value assignment without changing the index count (reference counting ). Copy: Create an object with an index count of 1 and release the old object. Retain: Release the old object, assign the value of the old object to the input object, and increase the index count of the input object to 1. The actual retain syntax is: -(Void) setname :( nsstring *) newname { If (name! = Newname ){ [Name Release]; Name = [newname retain]; // Name's retain count has been bumped up by 1 } } The following is the most important thing: ? If you don't know how to use them, then-> Use assign: for basic data types (nsinteger, cgfloat) and C data types (INT, float, double, Char, etc) Use copy: To nsstring Use retain: for other nsobject and its subclass Nonatomic Keyword: Atomic is a thread protection technology used by objc. It basically prevents reading data by another thread when the write is not completed, resulting in data errors. This mechanism consumes system resources. Therefore, nonatomic is a good choice for small devices such as the iPhone, if multi-thread communication programming is not used. |