Monitor file with some kind of persistent id

My app writes files to the users shared Documents directory. I save the files path but this breaks if the user changes the documents name, moves the document to a new location etc. Is there some kind of persistent file id i can use to keep track of these documents? i've been poking around

FileManager.default.attributesOfItem(atPath: docUrl.path)

and i find attributes like FileAttributeKey.systemFileNumber but this number seems to change every time i run the app. There has to be some way to keep track of files other than their path

Is there some kind of persistent file id i can use to keep track of these documents?

Yes, it’s called a bookmark. See the Creating a URL by Resolving a Bookmark topic group in the

URL
documentation.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Monitor file with some kind of persistent id
 
 
Q