Http://stackoverflow.com/questions/18526909/whether-i-should-use-propertynonatomic-copy-or-propertynonatomic-strong-fo
The ' copy ' would cause the setter for this property to create a copy of the object, and was otherwise identical to strong. You would use the sure if someone sets your property to a mutable string, then mutates the string, and you still Have the original value. If the string isn ' t mutable, Cocoa'll silently optimize out the copy operation, which are nice:)
' Strong ' would keep the property ' s value alive until it's set to something else. If you want incoming mutable strings-to-change out from under you (not impossible, but not all that common, a thi ng to want), then strong would is the right thing to do. Generally strong is more useful for objects, represent something more complex than a simple ' value ' (i.e. not nsstring , NSNumber, Nsvalue, etc ...).
' Assign ' is the default (and indeed only) possible setting for an integer. Integers can ' t be retained or copied like objects.
For attributes whose type was an immutable value class this conforms to the Nscopying protocol, you almost always should SP Ecify copy in your @property declaration. Specifying retain is something you almost never want in such a situation. In non ARC strong would work like retain
Here's why, you want
Nsmutablestring *Somename= [nsmutablestring Stringwithstring:@ "Chris" ];person *p = [[[person Alloc] Init] Autorelease];. Name = Somename;[somename setstring:@ "Debajit"
The current value of the Person.name property would be different depending on whether the property is declared retain or co Py-it would be @ ' Debajit ' If the property was marked retain, but @ ' Chris ' If the property is marked copy.
Since in almost all cases your want to prevent mutating an object ' s attributes behind it back, you should mark the Propert ies representing them copy. (And if you write the setter yourself instead of using @synthesize your should remember to actually use copy instead of RET Ain in it.)
The difference between copy and strong (or retain)