http://php.weenggs.com/scrap/service.php?op=search&search_term=Crabbie的 - >我的api http://php.weenggs.com/scrap/service.php?op=search&search_term=Crabbie%20 - >想要这样
[myStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
将空格转换为%20,就像我想要转换为%20一样。
答案 0 :(得分:0)
尝试使用stringByReplacingOccurrencesOfString
方法,
此处用's
%20
的出现
str=[str stringByReplacingOccurrencesOfString:@"'s" withString: @"%20"];
NSString *str=@"http://php.weenggs.com/scrap/service.php?op=search&search_term=Crabbie's";
str=[str stringByReplacingOccurrencesOfString:@"'s" withString: @"%20"];
NSLog(@"%@",str);
O / P: -
http://php.weenggs.com/scrap/service.php?op=search&search_term=Crabbie%20