(iPhone应用程序)错误:太多参数函数'URLWithString:'
问题描述:
我试图格式化一个URL字符串,但它是说有太多的参数。我的代码如下:(iPhone应用程序)错误:太多参数函数'URLWithString:'
-(IBAction)tweetRandom {
//NSLog(@"CALLED");
test = 100;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://twitter.com/%i", test]]; // problem line
}
任何人都知道如何格式化URL?希望有URLWithFormat
的名字,但它不存在。
答
您需要使用stringWithFormat:
这样的:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://twitter.com/%i", test]]];
哦,好的,谢谢! – Alex 2010-07-17 03:15:14