These are setter and getters.
-(NSMutableArray*)contactList
{
return contactList;
}
-(void)setContactList:(NSMutableArray*) aContactList
{
[contactList release];
contactList=aContactList; //its working fine but leaks
// contactList=[aContactList copy];
// If I keep like this getting exception as mutating
// object setting to immutable but it is mutable only.
}
In view controller, in edit functionality, I am adding new object to the list like this
[tempDetailsObj.contactList addObject:editcontacts];
here I am getting exception as mutating
object setting to immutable but it is mutable only.
If I remove copy its working fine but I am getting Leak, So I want to add the object to the list without any exception and it should not produce any leaks.
For starters, you are not taking ownership of the parameters passed to your setter. Also you’ll want to copy mutable instances to avoid them being changed under you.
Use e.g. this:
But then, why not use just use declared properties: