Override copyWithZone: in Objective-C

817 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 answers

0
Anoop Vaidya 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;
}