升级到xcode 4.6和iOS 6.1后出错"用作上一个参数的名称而不是选择器的一部分"

snk*_*snk 12 xcode objective-c ios xcode4.6 ios6.1

在更新到xcode 4.6和ios6.1之后,我得到了这个新错误"'objectType'用作前一个参数的名称,而不是作为选择器的一部分 ".我多次得到这个.有任何想法吗?

PS:它显示的方法是用于反向地理编码的自定义方法.

-(void) getAddress: (NSString *) objectType: (CLLocationCoordinate2D) objectCoordinate
Run Code Online (Sandbox Code Playgroud)

iDe*_*Dev 24

它表示这objectTypeNSString方法中对象的名称,而不是方法名称的一部分,不应该使用它,因为objectType: (CLLocationCoordinate2D) objectCoordinate它通常表示方法名称的一部分.

理想情况下你应该改变,

-(void) getAddress: (NSString *) objectType: (CLLocationCoordinate2D) objectCoordinate
Run Code Online (Sandbox Code Playgroud)

更具可读性

-(void) getAddress:(NSString *)objectType coordinate:(CLLocationCoordinate2D) objectCoordinate;
Run Code Online (Sandbox Code Playgroud)

上述错误也可以通过objectType在方法定义中放置一个空格和下一个参数来修复(例如: - -(void)getAddress:(NSString *)objectType : (CLLocationCoordinate2D)objectCoordinate).注意之后的空格objectType.

更新:

要回答评论中的问题,您可以使用以下行来禁止这些警告:

#pragma clang diagnostic ignored "-Wmissing-selector-name"
Run Code Online (Sandbox Code Playgroud)

在你的pch文件中添加它.我不确定这是否适用于你来自图书馆的情况,但你可以尝试一下.检查此clang-trunk以获取更多详细信息.

  • @Guven,不确定这是否有效,但你可以尝试在你的pch文件中使用`#pragma clang diagnostic ignored"-Wmissing-selector-name".更新了我的问题. (2认同)

Ale*_*ray 5

所有关于间距,亲爱的 ...正如@Martin R所说的那样:这个,有争议的更好的问题 ......

"在第二个参数之前插入一个空格就足够了."

足够的意义,在这里,Xcode关闭了地狱..

本着奇怪的合成琐事的精神......这是我最喜欢的Cocoa头文件,EVER.是的,这些都是有效的方法名称,呵呵.

@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
Run Code Online (Sandbox Code Playgroud)