When executing the following code I receive a run time error when the code executes the second line of code. The error (which shows up in the debugger) says: [NSButton initWithContentsOfURL:]: unrecognized selector sent to instance 0x100418e10. I don’t understand this message, because it looks to me (based on my source code) like the initWithContentsOfURL message is being sent to the myImage instance (of the CIImage class) … not NSButton. Any idea what is going on?
If it matters … this code is in the Application Controller class module of an Xcode project (a Cocoa application) — within a method that is called when I click on a button on the application window. There is only the one button on the window …
// Step1: Load the JPG file into CIImage
NSURL *myURL = [NSURL fileURLWithPath:@"/Users/Adam/Documents/Images/image7.jpg"];
CIImage *myImage = [myImage initWithContentsOfURL: myURL];
if (myImage = Nil) {
NSLog(@"Creating myImage failed");
return;
}
else {
NSLog(@"Created myImage successfully");
}
This line
Does assignment instead of comparison
Also, don’t put a space before parameter for your method in question. And it should be something like this: