4

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

AP.
  • 5,205
  • 7
  • 50
  • 94
  • You've asked 5 questions, but not accepted any answers. This is not in keeping with the spirit of Stackoverflow, and will discourage others from taking the time to help you. – Ben Gottlieb Jan 17 '10 at 14:06

1 Answers1

10
- (id) copyWithZone: (NSZone *) zone
{
    return [[UIImage allocWithZone: zone] initWithCGImage: self.CGImage];
}
Costique
  • 23,712
  • 4
  • 76
  • 79
  • 3
    I know this is pretty old but the solution presented here does not copy potential cap insets. The thing is, that I found no way to find out whether there are cap insets or not. The UIImage documentation states, that the `capinsets` property will return `UIEdgeInsetsZero` when the image is not created via `resizableImageWithCapInsets:` (the whole image is streched in this case). But it also returns `..Zero` when someone explicitly SETS the `capInsets` to be Zero (the image is tiled in this case). So I currently don't see any possibility to make UIImage compliant to NSCopying WITH capinsets. – floriankrueger Jul 25 '13 at 14:35