How to remove escaped characters from a path returned by NSSavePanel::url::path?

28 Views Asked by At

I'm using the following to let a user pick a file to save in my macOS app:

let panel = NSSavePanel()
let resp = panel.runModal()
if(resp == .OK)
{
    let strFilePath = panel.url?.path();
}

The problem is that NSSavePanel::url::path escapes spaces (and possibly other characters) in a path. So instead of:

/Users/user/Documents/file 2.txt

I'm getting:

/Users/user/Documents/file%202.txt

So how do I get it to return the former path?

0

There are 0 best solutions below