NSString *urlString = @"http://example.com/myzip?\"30339\"";
NSLog(@"urlstring: %@", urlString);
// RETURNS=> urlstring: http://example.com/myzip?"30339"
NSURL *url = [NSURL URLWithString:urlString];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
NSLog(@"request: %@", request);
// RETURNS=> request: <NSMutableURLRequest: 0x8f54480> { URL: (null) }
如果我的网址中有引号,我无法完成NSMutableURLRequest。有没有解决这个问题?
答案 0 :(得分:0)
"
不是在网址中使用的合法字符,必须转而转义(如%22
),如下所示:
http://example.com/myzip?%2230339%22