【发布时间】:2013-05-06 21:37:11
【问题描述】:
我很难让我的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"
【问题讨论】:
标签: nsstring nsurl nsstringencoding