문제

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top