In nonatomic, no guarantees are made for returning a whole value from the getter/setter, if some setter activity is going on any other thread.
Thus, nonatomic is considerably faster than atomic, and never thread-safe
In retain explicitly state that you want to maintain a reference of the object or you want to be the owner of the object, and you must release it before it will be deallocated. It will increase the reference count by 1.
-(void)setString:(NSString*)newString{
[newString retain];
[string release];
string = newString;
}
The copy is often used with strings, since making a copy of the original object ensures that it is not changed whilst you are using it.
-(void)setString:(NSString*)newString{
if(string!=newString){
[string release];
string = [newString copy];
}
}
While retain
simply increments the retain count of an object, copy
creates a new one one with its own retain count.