“Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL"”
bug產(chǎn)生的原因:
URL 不能包含 ASCII 字符集。
解決的辦法:
把url的字符串進(jìn)行如下處理遗菠。
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
/***
stringByAddingPercentEncodingWithAllowedCharacters 對(duì)字符串進(jìn)行編碼
URLFragmentAllowedCharacterSet "#%<>[\]^`{|}
URLHostAllowedCharacterSet "#%/<>?@\^`{|}
URLPasswordAllowedCharacterSet "#%/:<>?@[\]^`{|}
URLPathAllowedCharacterSet "#%;<>?[\]^`{|}
URLQueryAllowedCharacterSet "#%<>[\]^`{|}
URLUserAllowedCharacterSet "#%/:<>?@[\]^`
***/