Skip to content

Objective-C: Don’t make this mistake

Duct Tape, fixer of all things!It’s the little things that can drive a developer to jumping out a window. You plan a solution, code the solution, build the solution, run it, and… it doesn’t work. Most of the time you spot the problem right away, some times you’re left scratching your head, repeating over and over “this looks like it should work?” Of course you know better. It didn’t work, you just can’t see why. I had this problem last night so I thought I’d share with the world, ok not the world, just my electronic brain, so I can look it up later if necessary.

Here’s what I did.

@protocol Blah<NSObject>
-(void)somethingHappened
-(void)somethingElse
@end

Then I implemented the protocol.

@interface NeatoStuff : OtherStuff<Blah>
...
@end

Later, in a different hunk of code I want to send a message to that implementation, so I did something I’ve now done many, many, times. I check to see if the delegate I’ve been given actually answers the message(implements the method) I’d like to send.

SEL delegateSelector = @selector(somethingHappened:);
if ([_delegate respondsToSelector:delegateSelector])
{
    [_delegate performSelector:delegateSelector];
}

It didn’t work, and I couldn’t see why. Can you? I’ll wait, go ahead and look it over again, I’ll play some Jeopardy music while you work.

Did you spot the problem? It’s one little character. This…

SEL delegateSelector = @selector(somethingHappened:);

Should be this…

SEL delegateSelector = @selector(somethingHappened);

Yep, that’s it. One little “:” had me pulling my hair out, and I just couldn’t see the problem to save my life, at least not for about 10-minutes of outright frustration.

The message doesn’t expect to receive arguments, so the “:” is not necessary. Note to self: Don’t do that again.

Categories: Development.

Tags: ,

Comment Feed

2 Responses

  1. It looks like your just used to typing smily faces (:

  2. Yeah, I guess it does. :]



Some HTML is OK

or, reply to this post via trackback.

Tricor prescription drug coverage
Buy online lasix
Lamictal without prescription
Generic aricept
Invega 6 mg
Mulan clozapine prescription access system
Price of yaz birth control pill
Natural alternatives to clomid
500mg augmentin
Where to buy sporanox
Tetracycline generic
Generic vantin
How to know if your husband is having an affair
Are they cheating
Equipment gps tracking
How to know if guy is cheating
Ultram drug prescription
Ultram 100mg online
Buy ultram online without a prescription
Ultram 50mg info
Generic for ultram er
Ultram wean from canadian pharmacy
cheating spouse wife
how do you know your husband is cheating
Strattera 25 mg
Strattera 40mg
Strattera prescribing information
Male orgasm enhancer
signs that your spouse is cheating
signs your partner is cheating
viagra online canada prescriptions
buy tramadol online
buy tramadol online
50mg tramadol
pharmacy no prescripition tramadol capsules
tramadol buy online
generic cialis
buy tramadol online
buy synthroid online
order tramadol online
buy vibramycin
buy toradol
buy lidocaine
buy celebrex
buy flagyl
lasix furosemide
canadian family pharmacy
cialis online
tramadol 100mg
nexium generic
buy nolvadex
how to catch a cheating wife
generic viagra
Canadian Family Pharmacy
buy nolvadex