I have a need to convert from a full path starting with /Users/username/file.ext
to a tilde path ~/file.ext
. I see lots of ways built into NSString
and NSURL
that go from tilde to full but not the other way around. While I could go the route of using NSHomeDirectory()
and replacing within the path string, I was hoping for a way baked into Cocoa for handling this should things change.
The reason why I need this is because I am pushing Adobe JSX scripts from a Cocoa app. The Cocoa app gathers all the data needed for the script and pushes the data as arguments to the script. The File
class appears to require tilde-based paths (but not the Folder
class which is odd), but I cannot find anything definitive in their own documentation and am going by my own observations. Full paths fail while tilde paths do not.