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]]];
精彩评论