Objective-C code to generate a relative path given a file and a directory

Viewed 5741

Given a file path and a directory path as NSStrings, does anyone have Objective-C code to generate a path to the file, relative to the directory?

For example, given the directory /tmp/foo and the file /tmp/bar/test.txt, the code should produce ../bar/test.txt.

I know Python, at least, has a method to do this: os.path.relpath.

3 Answers
Related