这是我的代码,并在我的URL字符串空格不是由代码字符串修改不起作用?
NSString *str = item.fileArtPath;
NSCharacterSet *set = [NSCharacterSet URLQueryAllowedCharacterSet];
[str stringByAddingPercentEncodingWithAllowedCharacters:set];
[str stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
NSURL *urlString = [NSURL URLWithString:str];
下面的字符串编码:
http://xx.xx.xx.xxx:xx/xx/xx/xx/xxx/Audio Adrenaline.jpg
^^^^^^^^^^^^^^^^^^^^
我用过之后Audio
后的空格不会被转换为%20
字符串替换。而在调试urlString
是nil
为什么这么说?