NSOpenPanel 文件 URL 格式
我有一个 NSOpenPanel,我从中获取文件的 URL 并将其放入 NSString 中,如下所示:
imageURL = [[[panel URLs] objectAtIndex: 0] absoluteString];
然后,当我去保存文件(在与打开文件相同的位置)时,我使用这个:
[imageData writeToFile:[NSString stringWithFormat:@"%@/%@.%@", imageURL, imageName, imageType] atomically:NO];
这个问题是它不会保存到任何带有空格的位置。例如,该路径中有一个文件夹,如下所示:
This Folder
它将被放入字符串中,如下所示:
This%20Folder
但它当然无法保存到那个位置,因为它不对。我该如何解决这个问题?可以得到不做任何改变的实际字符串吗?谢谢。
I have a NSOpenPanel and I get the URL for the file from it and put it into an NSString like this:
imageURL = [[[panel URLs] objectAtIndex: 0] absoluteString];
Then when I go to save the file (in the same location as the file was opened) I use this:
[imageData writeToFile:[NSString stringWithFormat:@"%@/%@.%@", imageURL, imageName, imageType] atomically:NO];
Problem with this is that it won't save to any location with a space in. For example is there was a folder in that path like this:
This Folder
It would be put in the string like this:
This%20Folder
But it of course can't save to that location because its not right. How can I get around this? Possible to get the actual string with no changes? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个,
try this,