views:

96

answers:

1

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];
+6  A: 

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 slideBack with a capital B, which is probably what you're calling. The one that doesn't has a lowercase 'b' and is written slideback. 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.

Jason Coco
Alright, so it was just the late night, I guess when I can't tell the difference between lowercase and uppercase b it's time to call it a night... I'll accept this once it lets me...
Robert
The indent is a lie.
thyrgle
@thyrgle: It was formatted as XCode aligns it, with the semicolons in a line, but I think that pushed `pasteboard:` too far to the left and broke the formatting, so it messed everything else up...
Robert
@Robert: No, I was just stating that I kept thinking: "How could an indent cause an error?" when the whole problem was your capitalization.
thyrgle
Oh, yeah lol. I tried everything... except the proper function name, but hey.
Robert
@thyrgle: I thought that was some hidden portal reference, I was trying to figure out what it meant lol; the cake def /is/ a lie tho.
Jason Coco
@Robert: if Xcode doesn't highlight your method name (syntax color it), or it warns you, it's almost 99% guaranteed that you have a typo or misspelling in your method name, so check that first!
Jason Coco
@Jason: It was...
thyrgle