我有这个字符串
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
如您所见,不一样。我的问题是如何使用 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) 就在 and 被替换为 (448) 提前谢谢。