简体   繁体   中英

NSOpenPanel File URL Format

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.

尝试这个,

imageURL = [imageURL stringByReplacingPercentEscapesUsingEncoding:NSAsciiStringEncoding]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM