Re: misspelled methods
Re: misspelled methods
- Subject: Re: misspelled methods
- From: Andy Lee <email@hidden>
- Date: Tue, 18 Aug 2009 11:21:33 -0400
On Tuesday, August 18, 2009, at 10:48AM, "Sean McBride" <email@hidden> wrote:
>On 8/17/09 8:00 PM, Todd Heberlein said:
>
>>I just spent about an hour trying to track down a bug. It turns out
>>that instead of typing
>>
>> - (void)viewDidLoad
>>
>>I typed
>>
>> - (void)viewDidload
>>
>>with a lower case 'L' in "load".
>>
>>It reminds me of programming languages where if you mistype a variable
>>name the compiler just happily assumes you want a new variable and
>>creates one for you. I hate those languages.
>>
>>Is there any way for me to get Xcode to complain when it runs into a
>>method implementation that was not previously declared in a header file?
>
>I don't think so. I'd suggest against that anyway, because it means you
>would be polluting your public .h file with private method
>declarations. Besides, you'd probably just copy-paste your typo anyway.
>
>However, gcc can warn if you send an unknown message to an object. Take
>a look at: -Wstrict-selector-match -Wundeclared-selector
That would catch some typos, but wouldn't have helped Todd since he probably never sends the viewDidLoad method himself. The nearest thing I can think of would be something like Java annotations, where you can mark a method as @Override. True, you have to remember to do that, so you're back to dealing with human fallibility, but in order to accidentally screw yourself you would have to *both* misspell the name *and* forget the @Override tag. Another thing that might help would be for auto-completion to be smarter while you're entering a method declaration. (Weird -- I just entered "- (NSString *)descriptio" and -description was not offered as a possible completion. Will file a Radar.) In the end, though, I think this might just be an inherent pitfall of object-oriented programming. Even making the language case-insensitive wouldn't protect you from dyslxeic typos or things that are spelled correctly but are the wrong thing. You still have to fall back on plain old debugging and having a good proofreader's eye.
--Andy
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden