xcode 方法调用的参数太多,预期为 1,有 2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13390628/
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
Too many arguments to method call, expected 1, have 2
提问by chrisjr
I am using TWTweetComposeViewController
for iOS 5 legacy in my app. For some reason, I am receiving a "Too many arguments to method call, expected 1, have 2" error."
I have tried looking for answers in similar questions, but they haven't helped me so far.
我TWTweetComposeViewController
在我的应用程序中使用iOS 5 旧版。出于某种原因,我收到了一个"Too many arguments to method call, expected 1, have 2" error."
我已经尝试在类似问题中寻找答案的消息,但到目前为止他们还没有帮助我。
Here is the code:
这是代码:
TWTweetComposeViewController *tweetSheet =
[[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText:@"%@", [[_items objectAtIndex:indexPath.row] objectForKey:@"redirect_url"]];
[self presentModalViewController:tweetSheet animated:YES];
Any ideas? Thanks in advance.
有任何想法吗?提前致谢。
回答by Edwin Iskandar
Like the error says, you have too many arguments. You need to use NSString's stringWithFormat method to create your dynamic string:
就像错误所说的那样,你有太多的论点。您需要使用 NSString 的 stringWithFormat 方法来创建您的动态字符串:
[tweetSheet setInitialText:[NSString stringWithFormat:@"%@", [[_items objectAtIndex:indexPath.row] objectForKey:@"redirect_url"]]];
回答by MaxGabriel
You need to use [NSString stringWithFormat:@"%@",object];
to make a format string.
您需要使用[NSString stringWithFormat:@"%@",object];
来制作格式字符串。