xcode 警告-用作前一个参数的名称而不是选择器的一部分

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18247315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 03:42:18  来源:igfitidea点击:

Warning-used as the name of the previous parameter rather than as part of the selector

objective-cxcode

提问by Arun Iphone

I am using a function in a class as below

我在类中使用一个函数,如下所示

- (void) uploadMorePic:(NSDictionary *) MuliPics: (NSData *)file  

It shows the warning - MuliPicsused as the name of the previous parameter rather than as part of the selector

它显示警告 - MuliPics用作前一个参数的名称而不是选择器的一部分

Why that comes ?

为什么会这样?

Screenshot for example

截图例如

回答by dpassage

It's a poor message, but it's because you didn't provide a name for the first parameter to your method. Try this:

这是一个糟糕的消息,但这是因为您没有为方法的第一个参数提供名称。尝试这个:

-(void)uploadMorePic:(NSDictionary *)dict muliPics:(NSData *)file

I also fixed a style issue; the name of the second part of the method name should start with a lower-case letter. I don't know what your method does, so you may be able to come up with a better name.

我还修复了一个样式问题;方法名称的第二部分的名称应以小写字母开头。我不知道你的方法是做什么的,所以你可以想出一个更好的名字。

回答by Wain

Because you haven't separately specified the parameter name and the selector definition. Basically, you're missing a space and/or a word. Try:

因为你还没有分别指定参数名和选择器定义。基本上,您缺少一个空格和/或一个单词。尝试:

-(void)uploadMorePictures:(NSDictionary *)pics withFile:(NSData *)file

Which separately names and specifies both parameters to the method.

其中分别命名和指定方法的两个参数。

回答by Artisan

@dpassage 's answer is nice。

@dpassage 的回答很好。

The function name of objective-c is not like C or C++, it has some parameter and the same num of description of parameter name。 In your case, you did not set your first parameter name or you did not set your description of your second parameter name.

Objective-c 的函数名不像 C 或 C++,它有一些参数和参数名的描述数量相同。 在你的情况下,你没有设置你的第一个参数名或者你没有设置你的第二个参数的描述参数名称。

What @dpassage said was the first condition, missing first parameter name.

@dpassage 所说的是第一个条件,缺少第一个参数名称。