我正在尝试获取某个文件的路径
,然后在 webview 中打开它。所以我需要用 '%20' 替换每个空格
NSString *test=@"filename";
NSString *finalPath12 = [test stringByAppendingString:@".pdf"];
NSString *path1 = [[NSBundle mainBundle] bundlePath];
NSString *finalPath1 = [path1 stringByAppendingPathComponent:finalPath12];
NSString *file =@"file://";
NSString *htmlfilename1 = [file stringByAppendingString:finalPath1];
NSString *pathtofile = [htmlfilename1 stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
除 @"%20" 之外的任何字符串都在工作。
这非常适用于示例:
NSString *pathtofile = [htmlfilename1 stringByReplacingOccurrencesOfString:@" " withString:@"string"];
但我需要@"%20"。我错过了什么?谢谢