What format do the app-open-doc functions expect from their "String" parameters?

NSApplicationDelegate.application(_:open:) gets the files it needs to read from the file URLs given. There are similar older functions that use a String to identify the file. What format are those strings expecting? A path name? An URL?

Answered by DTS Engineer in 871035022

NSApplicationDelegate.application(_:open:) gets the files it needs to read from the file URLs given. There are similar older functions that use a String to identify the file. What format are those strings expecting? A path name? An URL?

NextStep (yes, this is that old) originally used standard UNIX paths for file references, while NSURL/CFURL were added as a more "universal" object reference and as a bridge layer between Foundation, CoreFoundation, and the Carbon File Manager. Over time, it's become increasingly clear what a terrible idea straight file paths are, so we've deprecated the string path methods/delegates in favor of URLs. While that transition is far from complete (for example, many URL methods are still wrappers around the original path methods), my general advice is to avoid string-based paths whenever possible.

In terms of the specific question here:

What format are those strings expecting?

It's standard UNIX-style path, but if you want a specific example, calling NSURL.path() on a file URL will give you the equivalent string path.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

NSApplicationDelegate.application(_:open:) gets the files it needs to read from the file URLs given. There are similar older functions that use a String to identify the file. What format are those strings expecting? A path name? An URL?

NextStep (yes, this is that old) originally used standard UNIX paths for file references, while NSURL/CFURL were added as a more "universal" object reference and as a bridge layer between Foundation, CoreFoundation, and the Carbon File Manager. Over time, it's become increasingly clear what a terrible idea straight file paths are, so we've deprecated the string path methods/delegates in favor of URLs. While that transition is far from complete (for example, many URL methods are still wrappers around the original path methods), my general advice is to avoid string-based paths whenever possible.

In terms of the specific question here:

What format are those strings expecting?

It's standard UNIX-style path, but if you want a specific example, calling NSURL.path() on a file URL will give you the equivalent string path.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

What format do the app-open-doc functions expect from their "String" parameters?
 
 
Q