You must add the NSCopying protocol to your class interface.
@interface MyCustomClass : NSObject <NSCopying>
Then the method should be:
- (id)copyWithZone:(NSZone *)zone { MyCustomClass *result = [[[self class] allocWithZone:zone] init];
NSObject does not comply with the NSCopying protocol. That is why you cannot call super copyWithZone:
Edit: based on Roger's comment, I updated the first line of code in the copyWithZone: method. But, based on other comments, the zone can be safely ignored.
source share