I have created one class which is subclass of NSObject(nsme as GroupClass).In that class I have created one property which is belonging from 'id' ,like
@property(nonatomic,retain)id myObj;
Now I am standing on way where I have one mutable array,that array contains instances of my GroupClass.so I am getting one copy in similar way
GroupClass* objG=[array objectAtIndex:i];
now I want one another copy of objG.I searched .And I found NSCopying Protocol.So I added as delegate NSCopying to GroupClass and also added copyWithZone method.Here it is
-(id)copyWithZone:(NSZone *)zone
{
GroupClass *copy = [[[self class] allocWithZone: zone] init];
copy.myObj=[myObj copyWithZone: zone];
return copy;
}
Here I need deep copy.but it is always crashing after allocation line.Please help me.Thanking You.