I have a NSURL to a local file with no base url. I want to change the base URL to another local directory, with the relative path being in respect to that URL. For example
NSURL *path = [NSURL fileURLWithPath: @"/Users/username/Desktop/Photos/Photo1.jpg"];
Now, say I want to change the base part to /Users/username/Desktop/SomeFolder
, then I would want the NSString returned by [path relativePath];
to be "../Photos/Photo1.jpg"
Is there an easy way to do this? I can't seem to find any NSURL methods that do this. I could go through the path components of the new base and old absolute paths to construct the relative part my self, but is there an easier way?