2010-07-29 41 views
0

我想格式化一個URL,但我得到了一個錯誤。我的代碼如下。(iPhone)URL格式問題

NSString *twitterURL = [NSString stringWithFormat:@"http://twitter.com/?status=My%20score%20is:%i%20and%20CharsPerMin%20is:%@", currentScore, charPerMin.text]; 

當調用該方法時,它不會執行任何操作。我認爲這個問題是%20。正在使用%20來隔離URL中的每個單詞。

回答

3

你需要他們加倍逃避你%跡象:

NSString *twitterURL = [NSString stringWithFormat:@"http://twitter.com/?status=My%%20PracticeTyper%%20score%%20is:%i%%20and%%20CharsPerMin%%20is:%@", currentScore, charPerMin.text]; 
+0

那好吧,謝謝你。很棒。 – Alex 2010-07-29 08:50:54