How do i make a deep copy using copyWithZone so that each object in array1 is duplicated in the array2 with its own copy. So if i make changes in array1 it wont affect array2
this is main.m
@autoreleasepool {
NSArray *array1 = @[fbUser1, fbUser2, fbUser3];
NSArray *array2 = [array1 copy];
}
this is UserClass.h
@interface FbUser : NSObject <NSCopying>{
}
now in UserClass.m i have copyWithZone
- (id)copyWithZone:(NSZone *)zone
{
id copy = [[[self class] alloc] init];
if (copy) {
}
return copy;
}
I have searched the docs but could not get it to work. Any help would be highly appreciated.