Objective c stringByReplacingOccurrence不替换字符串

Objective c stringByReplacingOccurrence不替换字符串,objective-c,ios,parsing,nsfilemanager,Objective C,Ios,Parsing,Nsfilemanager,我需要解析应用程序中的文件URL,并将%20替换为一个空格。我正在使用stringByReplacingOccurance: NSString *strippedContent = [finalFilePath stringByReplacingOccurrencesOfString:@"%20" withString:@" "]; 但当我在NSLog中显示strippedContent时,所有的%20字符串仍然存在。下面是我希望解析的文件名示例: .../Documents/Inbox/Te

我需要解析应用程序中的文件URL,并将%20替换为一个空格。我正在使用stringByReplacingOccurance:

NSString *strippedContent = [finalFilePath stringByReplacingOccurrencesOfString:@"%20" withString:@" "];
但当我在NSLog中显示strippedContent时,所有的%20字符串仍然存在。下面是我希望解析的文件名示例:

.../Documents/Inbox/Test%20Doc%20From%20Another%20App.txt
似乎NSFileManager在文档中包含%20时找不到该文档。
文件路径正在通过“在…中打开”对话框从另一个应用程序传递。是否有任何方法可以在导入URL时删除带有stringByReplacingOccurrence的%20?

NSString
提供了一种执行所需转换的方法:

NSString *strippedContent = [finalFilePath stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
是的,您应该使用:

NSString * strippedContent = [finalFilePath stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

我尝试了以下代码NSString*finalFilePath=@“../Documents/Inbox/Test%20Doc%20From%20other%20App.txt”;NSString*strippedContent=[finalFilePath stringByReplacingOccurrencesOfString:@“%20”带字符串:@”“];//在这里插入代码。。。NSLog(@“%@”,带条内容);我得到了输出“../Documents/Inbox/Test Doc From other App.txt”我认为您的代码工作正常。他想删除转义百分比,而不是添加它们。@Evan Mulawski抱歉,已修复it@self-您的答案与
@dasblinkenlight
答案有什么区别?需要注意的是,这只会删除百分比符号,他们必须使用NSString*strippedContent=[finalFilePath stringByReplacingOccurrencesOfString:@“20”和String:@”“]执行另一次传递;