NSURL无法解析带有|符号的URL?
NSURL *url = [NSURL URLWithString:@"http://ac-g405gbtt.clouddn.com/NT326NQNJZ3DkQo4V3VRG7B?auto-orient|imageInfo"];
NSLog(@"url : %@",url);// url : (null)
为什么url中带有 | 生成的NSURL会为nil?
怎么解决?
ios afnetworking url objective-c
二姨求打脸
9 years, 7 months ago
Answers
请尝试如下代码:
// 原始URL
NSString *urlString = @"http://ac-g405gbtt.clouddn.com/NT326NQNJZ3DkQo4V3VRG7B?auto-orient|imageInfo";
// 经过转义的URL
NSString *newUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:newUrlString];
NSLog(@"url : %@",url);
纯洁的板子
answered 9 years, 7 months ago