链接中包换中文,会导致创建NSURL对象的时候,为nil。 下面是兼容代码
//兼容一下 链接中含有中文
-(NSURL *)cz_URLWithString:(NSString *)stringURL{if (stringURL.length ==0) {return nil;}NSURL *url = [NSURL URLWithString:stringURL];if (!url) {NSString *tmpStringURL = [stringURL stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];url = [NSURL URLWithString:tmpStringURL];}return url;
}