我有這個字符串stringWithFormat和%沒有工作
NSString *jsonString = @"http://www.soccerway.com/a/block_home_matches?block_id=block_home_matches_14&callback_params=%7B%22date%22%3A%222012-07-31%22%2C%22display%22%3A%22all%22%7D&action=showMatches¶ms=%7B%22competition_id%22%3A721%7D";
NSLog(@"%@",jsonString);
the output is
http://www.soccerway.com/a/block_home_matches?block_id=block_home_matches_14&callback_params=%7B%22date%22%3A%222012-07-31%22%2C%22display%22%3A%22all%22%7D&action=showMatches¶ms=%7B%22competition_id%22%3A721%7D
當我使用
NSString *linkId = @"448";//not a constant value only for example
NSString *jsonString = [NSString stringWithFormat:@"http://www.soccerway.com/a/block_home_matches?block_id=block_home_matches_14&callback_params=%7B%22date%22%3A%222012-07-31%22%2C%22display%22%3A%22all%22%7D&action=showMatches¶ms=%7B%22competition_id%22%3A%@%7D",linkId];
the output is
http://www.soccerway.com/a/block_home_matches?block_id=block_home_matches_14&callback_params=7 37040ate23A222㿠 37040isplay23A0x1.21800000507cp-1027ll27D&action=showMatches¶ms=7 –ompetition_id23A(null) 0
,你看到的不是same.My問題是如何使用stringWithFormat得到這個結果:
http://www.soccerway.com/a/block_home_matches?block_id=block_home_matches_14&callback_params=%7B%22date%22%3A%222012-07-31%22%2C%22display%22%3A%22all%22%7D&action=showMatches¶ms=%7B%22competition_id%22%3A448%7D
所以值(721)剛剛在和被替換爲(448) 預先感謝。
謝謝你現在工作得很好。 paxdiablo和Kjuly謝謝 – adellam 2012-07-31 02:59:55
這是一個很好的解決方案! – Kjuly 2012-07-31 03:05:09