I learned new concept, so this post will be about something…lets move on. I have used (retain) @property for objects before, on many tutorial codes i have seen (copy) semantics used for NSMutableArray, NSString etc. I wanted to know the difference between (retain) and (copy) and when to use on what situation? I did search online forums, tutorials etc for informaion and found that:
(retain) retains the object before assignment and takes the ownership. If i assign object (setter) and change the state of object, it will reflect on same original object that was being assigned. But (copy) creates a new(another copy) of object, if i change state then it won’t reflect on first object that was assigned but to new(another copy) object. For example:

NSMutableString *name = @"Leonard";
[email protected] (retain, nonatomic) NSMutableString *characterName;
self.characterName = name;
[characterName setString:@"Sheldon"];

name object will have value “Sheldon”, since characterName is taking the ownership of the object by retaining it before assignment.

[email protected] (retain, nonatomic) NSMutableString *characterName;

name object will remain “Leonard”, since characterName has been assigned another copy upon assignment.

There is more but i’l come to problem that i faced. So i had an mutable array member of a my class, I used (copy) semantics for creating setter and getter, so as usual i assigned an mutable array to my member (synthesizer). Now later on i was adding object to my mutable array member, and program crashed. Yes program crashed, and it was very intersting find when i saw the nature of crash. Nature of crash was that i was adding object to NSArray not NSMutableArray, and as we know NSArray is immutable which cannot be modified hence a crash. So later i found that since i am using (copy) semantics so my implicit synthesizer makes a copy instead of retaining it but the real thing is that copy returns a immutable object, even if copy is being called on mutable. So the object whom i was thinking as mutable turned up as immutable and my program crashed.

Using (retain) makes it work if u want mutable, but there is a mutablecopy also, i haven’t tried that yet but you can write your own mutator, use mutablecopy and see if it return mutable or immutable. The implicit synthesizer will always use copy and assign immutable object.