Is Apple declaring method [CIImage initWithImage:(CIImage*)] that I'm not aware of? The only method with that signature that I'm aware of is [CISampler initWithImage:]. But when I tried to provide my own method, the compiler warns me saying that the method already exists.
Background: I'm trying to create a convenience method that converts an NSImage instance to CIImage. Then I created a category method [CIImage initWithImage:] that takes in an NSImage instance.
Here is the category method declaration:
@interface CIImage (QuartzCoreExtras)
-(id) initWithImage:(NSImage*) img;
@end
I tried to use it in an NSImageView subclass to cache the CoreImage version of the image:
-(void) setImage:(NSImage *)newImage {
[super setImage:newImage];
[ciImage release];
ciImage = [[CIImage alloc] initWithImage:newImage];
}
But when I compile the above method, I get a warning saying that someone else have already defined the method and it takes a different parameter:
warning: incompatible Objective-C types 'struct NSImage *', expected 'struct CIImage *' when passing argument 1 of 'initWithImage:' from distinct Objective-C type
From the "Jump to Definition" option in XCode, the only other implementation of the method (besides my own implementation) is [CISampler initWithImage:(CIImage*]. I'm really puzzled by this issue -- is there anything I did wrong?
Just for completeness' sake, here is the method body for [CIImage initWithImage:]:
@implementation CIImage (QuartzCoreExtras)
-(id) initWithImage:(NSImage*) img {
NSData* tiffData = [img TIFFRepresentation];
NSBitmapImageRep* bitmap = [NSBitmapImageRep imageRepWithData:tiffData];
return [self initWithBitmapImageRep:bitmap];
}
@end
Thanks in advance.