Alright, I’m reading the Aaron Hillegass book for Cocoa Programming, on the drag and drop chapter. I was following along with one of the lessons, and I typically change variable names as I find it keeps me a little more engaged and gives me a better understanding. I started getting this error, though:
2010-10-04 00:38:06.699 TypingTutor[421:a0f] -[BigLetterView dragImage:at:offset:event:pasteboard:source:slideback:]: unrecognized selector sent to instance 0x100424390
Now, I figured it was because I’d messed up some variable name so I went back and copied the variables directly from the book and still got the error. XCode was saying the following function might not get a response. Well, regardless I could not figure it out for the life of me, so I scrapped the function and redid it. What drives me crazy is that it worked the second time, but I did notice a difference in that XCode highlighted the syntax of the function that works, but didn’t for the one that doesn’t. I can see no physical difference and am stumped as to why one is different than the other. Both were typed in on a Mac keyboard, so I can’t see it being some hidden character due to encoding, but yeah, I’m just hoping I’m missing something extremely obvious because it’s 1 AM… has anyone ever run into this before?
Methods copied directly from .m file…
This one works
[self dragImage:anImage
at:p
offset:NSMakeSize(0,0)
event:mouseDownEvent
pasteboard:pb
source:self
slideBack:YES];
This one doesn’t
[self dragImage:anImage
at:p
offset:NSMakeSize(0,0)
event:mouseDownEvent
pasteboard:pb
source:self
slideback:YES];
Objective-C is case sensitive, so method names with different cases in their letters are considered different methods. The one that works, “slideback” is written
slideBackwith a capital B, which is probably what you’re calling. The one that doesn’t has a lowercase ‘b’ and is writtenslideback. In Objective-C, those are different methods. The definition is obviously written with the uppercase ‘B’, which is why that one works and the other doesn’t.