我很难让我NSURL
的工作,当我在转换为URL
它之前创建最终字符串时,会在字符串的末尾添加不需要的字符,为什么会发生这种情况,我该如何解决?
这是我的代码:
NSString *remotepathstring = [[NSString alloc] init];
remotepathstring=newdata.remotepath;
NSLog(@"remotepathstring = %@",remotepathstring);
NSString *remotepathstringwithescapes = [remotepathstring stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"remotepathstring = %@",remotepathstringwithescapes);
remotepathURL =[NSURL URLWithString:remotepathstringwithescapes];
NSLog(@"RemotePathUrl=%@",remotepathURL);
日志输出如下:
"remotepathstring = http://nalahandthepinktiger.com/wp-content/uploads/nalah-sheet-5.pdf"
"remotepathstring = http://nalahandthepinktiger.com/wp-content/uploads/nalah-sheet-5.pdf%E2%80%8E"
"RemotePathUrl=http://nalahandthepinktiger.com/wp-content/uploads/nalah-sheet-5.pdf%E2%80%8E"