“Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL"”
bug产生的原因:
URL 不能包含 ASCII 字符集。
解决的办法:
把url的字符串进行如下处理。
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
/***
stringByAddingPercentEncodingWithAllowedCharacters 对字符串进行编码
URLFragmentAllowedCharacterSet "#%<>[\]^`{|}
URLHostAllowedCharacterSet "#%/<>?@\^`{|}
URLPasswordAllowedCharacterSet "#%/:<>?@[\]^`{|}
URLPathAllowedCharacterSet "#%;<>?[\]^`{|}
URLQueryAllowedCharacterSet "#%<>[\]^`{|}
URLUserAllowedCharacterSet "#%/:<>?@[\]^`
***/
网友评论