Search code examples
objective-cmacosnsfilemanager

Cannot create a file by this path "file://localhost/users/admin/Desktop/" by XCode


My username on Mac OS is "admin", and I used NSOpenPanel to get the output path, the result is:

file://localhost/Users/admin/Desktop

However I use NSFileManager to createFileAtPath, nothing happens. If I change the path to /Users/admin/Desktop , the file will be created successfully. Could you please tell me why?

Also I found on Mac OS X 10.8 I get the Desktop path is "file://localhost/Users/admin/Desktop", but on 10.9 I got "file:///Users/admin/Desktop"...strange


Solution

  • I have solved it. use [url path] can get the NSString path.