开发者

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.


try this,

imageURL = [imageURL stringByReplacingPercentEscapesUsingEncoding:NSAsciiStringEncoding]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜