下面是我需要创建的字符串作为GET请求的URL。我总是在NSURL中获得零。 任何人都可以帮助我吗?
http://example.com/webexternal1/api/Values/sendorder?orderlist={code:"122|155",rate:"60|5",qty:"5|5"}&tab=N2
//strParams = {code:122|155,rate:60|5,qty:5|5}&tab=N2
dataUrl = [@"http://example.com/webexternal1/api/Values/sendorder?orderlist=" stringByAppendingString:strParams];
urlComponants = [[NSURLComponents alloc]initWithString:dataUrl];
NSURL *url = urlComponants.URL;
答案 0 :(得分:1)
尝试对strParams进行url编码。
NSString* strParams = [@"{code:122|155,rate:60|5,qty:5|5}&tab=N2" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];