Error after upgrading to xcode 4.6 and iOS 6.1 "used as the name of the previous parameter rather than as part of the selector"
Asked Answered
S

3

12

After updating to xcode 4.6 and ios6.1, I get this new error "'objectType' used as the name of the previous parameter rather than as part of the selector". I get this multiple times. Any ideas?

PS: The method that it get displayed is a custom one for reverse geocoding.

-(void) getAddress: (NSString *) objectType: (CLLocationCoordinate2D) objectCoordinate
Sacramental answered 29/1, 2013 at 7:10 Comment(0)
A
24

It says that objectType is the name of the NSString object in your method and not part of the method name and it should not be used as objectType: (CLLocationCoordinate2D) objectCoordinate which normally denotes a part of method name.

Ideally you should change,

-(void) getAddress: (NSString *) objectType: (CLLocationCoordinate2D) objectCoordinate

to a more readable,

-(void) getAddress:(NSString *)objectType coordinate:(CLLocationCoordinate2D) objectCoordinate;

The above error can also be fixed by putting a space between objectType and next param in method definition(For eg:- -(void)getAddress:(NSString *)objectType : (CLLocationCoordinate2D)objectCoordinate). Note the space after objectType.

Update:

To answer the question in comments you can use the below line to suppress these warnings:

#pragma clang diagnostic ignored "-Wmissing-selector-name"

Add this in your pch file. I am not sure if this will work for your case where it comes from library but you can try it out. Check this clang-trunk for more details.

Augmentation answered 29/1, 2013 at 7:20 Comment(4)
If the methods belong to you, then you can go ahead and make these changes and fix the warning. Would you have any suggestions on what to do if the warnings come from a library that you are using? Any build settings that you have come across maybe?Brawley
@Guven, Not sure whether this will work but you can try with #pragma clang diagnostic ignored "-Wmissing-selector-name” in your pch file. Updated my question.Augmentation
Correction: Updated my answer".Augmentation
@ABC, you have a so called "smart quote" at the end of your pch #pragma.Croupier
F
5

It's all about the spacing, darling... as @Martin R said re: this, debateably BETTER question...

"It is sufficient to insert a space before the second parameter."

Sufficient meaning, here, that Xcode shuts the hell up..

In the spirit of that odd piece of syntatic trivia... here's my favorite Cocoa header file, EVER. and yes, those are all valid method names, hehe.

@interface NSString (JASillyString)
-:a;
-:a :b;
-:a :b :c;
-:a :b :c :d;
-:a :b :c :d :e;
-:a :b :c :d :e :f;
-:a :b :c :d :e :f :g;
-:a :b :c :d :e :f :g :h;
-:a :b :c :d :e :f :g :h :i;
-:a :b :c :d :e :f :g :h :i :j;
-:a :b :c :d :e :f :g :h :i :j :k;
-:a :b :c :d :e :f :g :h :i :j :k :l;
-:a :b :c :d :e :f :g :h :i :j :k :l :m;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :v;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :v :w;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :v :w :x;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :v :w :x :y;
-:a :b :c :d :e :f :g :h :i :j :k :l :m :n :o :p :q :r :s :t :u :v :w :x :y :z;
@end
Flosser answered 1/3, 2013 at 0:14 Comment(0)
E
0

Your method is declaring the selector With spaces,

-(NSString *)testMethod:(double)price :(BOOL)flag;

Note mention .h and .m both are same and equal spaces

When retrive methode, that time careful about method and its arguments. like [self testMethod:4.5(space):TRUE];

Extended answered 20/2, 2013 at 12:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.