Reputation: 1183
In NSImage class reference it is said that there exist method initWithData
, but why xCode says it doesn't exist?
I use it like this:
NSData *imgData = [[imageView image] TIFFRepresentation];
fotoImg = [NSImage initWithData:imgData];
And i get warning:
Class method '+initWithData:' not found (return type defaults to 'id')
Why is this happening?
Upvotes: 0
Views: 1501
Reputation: 5705
You are calling initWithData
on the class when you should call it on an instance of that class. Do this: [[NSImage alloc] initWithData:imgData];
It is very important to learn the difference between member functions and class functions (or in Obj C terms "messages"). I recommend http://www.amazon.de/Programming-Objective-C-Automatic-Reference-Developers/dp/0321811909/ref=pd_sim_sbs_eb_1/276-1733140-9413556.
Upvotes: 4