有时候网络请求会异常,比如报错:
NSURLConnection finished with error - code -1002
Response failed, error buffer: unsupported URL
处理方法:
iOS 8 要用utf8转码:
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
iOS 8 以后要用这个方法:
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"#%^{}\"[]|\\<> "].invertedSet];