2010-07-17 75 views
1

我試圖格式化一個URL字符串,但它是說有太多的參數。我的代碼如下:(iPhone應用程序)錯誤:太多參數函數'URLWithString:'

-(IBAction)tweetRandom { 

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

} 

任何人都知道如何格式化URL?希望有URLWithFormat的名字,但它不存在。

回答

2

您需要使用stringWithFormat:這樣的:

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

哦,好的,謝謝! – Alex 2010-07-17 03:15:14