Search code examples
objective-cmacoscocoafoundation

Set NSTask working directory


How do I set the working directory of an NSTask. The obvious choice is currentDirectoryPath, but it is deprecated.

The program I am running needs to be run in a specific directory.


Solution

  • The obvious choice is currentDirectoryURL.

    Apple is going to replace all (NS)String path related API with (NS)URL related API.

    • currentDirectoryPath is deprecated in 10.13 but still operational.
    • currentDirectoryURL is introduced in 10.13.

    The same occurs to launchPath which will become executableURL