File References and Bookmarks

One problem with paths and regular file URLs is that they are fragile in the face of changes to the file system. You can create a path or URL that points to a file, and the user could move that file in the Finder behind your back. If you then try to get metadata or open the file, you could fail because the file is no longer living where you think it is living.

File references

A special kind of URL, called a file reference URL, tracks a file by its ID. This means the reference is still good even if the name or location of the file changes in the file system. Usually this is hidden behind classes like NSDocument, but it can be useful in other contexts aside from document files.

Get a file reference URL from a regular ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.