OC in iOS is an object-oriented editing language, each object is an instance of the class, and in OC each object has a pointer to the object named Isa, which points to its class. All nsobject are a struct that contains the ISA pointer.
(1) Assign and weak are a weak reference;
(2) strong is strongly quoted;
Weak references and strong references in the process of referencing the most important is caused by memory changes, and memory management, in the Setter method assignment process, the value of the pointer will change, before using each instance of the pointer number is 1,,alloc,release +1, after use to free memory, The Dealloc is performed at 1, and after 1 is reduced to 0, the Dealloc is released. Examples are as follows. The specific assignment code:
(1)-Property (Nonatomic, assign) NSObject * A;
-(void) SetA: (int) a {
-A = A;
}
In the case of a weak reference, the assignment is directly, that is, the value of the original pointer is 1, the assignment does not increase the number of pointers, or 1;
(2) -Property (Nonatomic, Strong) NSObject * A;
-(void) SetA: (int) a {
[_a release];
-A = [a strong];
}
In the case of reference, after +1 is assigned, after use-1 is still 1, return to the previous state, set to nil.
and assign, after use does not carry out-1, or 1, but the point of the thing is not, always no change, and will not point to nil, so there will be chaos.
Before writing a Gobang small game, encountered this problem, assign and strong use error, encountered the system shows an unexpected error.
Example can access my GitHub address: Https://github.com/leroypus/-,ios novice, wrong can leave a message, thank you
The difference between Ios-strong and assign