Override copyWithZone: in Objective-C

834 Views Asked by At

Can someone tell me how can one override -copyWithZone:

Assuming I have one NSString object, NSInteger object as class members.

1

There are 1 best solutions below

0
On BEST ANSWER

Subclass the class for which you need to override copyWithZone:.

Your sublclass should use the method similar to below:

- (id)copyWithZone:(NSZone *)zone {
    YourClass *copy = [[YourClass alloc] initWith...:<value>];
    return copy;
}