开发者

(iPhone app) error: too many arguments to function 'URLWithString:'

开发者 https://www.devze.com 2023-01-07 08:01 出处:网络
I\'m trying to format a URL string however it\'s saying there are too many arguments. My code is below:

I'm trying to format a URL string however it's saying there are too many arguments. My code is below:

-(IBAction)tweetRandom {

 //NSLog(@"CALLED");
 test = 100;
 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://twitter.com/%i", test]]; // problem line

}

Anyone know开发者_开发技巧 how to format the URL? Was hoping there was something by the name of URLWithFormat but it doesn't exist.


You need to use stringWithFormat: like this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://twitter.com/%i", test]]];
0

精彩评论

暂无评论...
验证码 换一张
取 消