make UIImage conform to the NSCopying protocol

2019-04-09 12:40发布

问题:

The question is quite simple, I need to have an UIImage conform to NSCopying protocol but I have absolutely no idea on where to start to achieve this.

Do you have any pointer to help me?

Thanks in advance

回答1:

- (id) copyWithZone: (NSZone *) zone
{
    return [[UIImage allocWithZone: zone] initWithCGImage: self.CGImage];
}