How to get File/Folder Rename Event in Finder Extension in a Cocoa app?

I am developing a Cocoa application with Finder Extension to set overlay icons on the file.


Apple provides the following Methods by default:

  • beginObservingDirectoryAtURL
  • endObservingDirectoryAtURL
  • requestBadgeIdentifierForURL


In addition to these, can I get other file events like: Rename, Delete, Create, Move etc. on finder.


My motive is to update the overlay icon for a file that has been renamed. I currently can't do this as i don't get an event for the same. (Please feel free to suggest any alternatives, like refreshing the Finder etc.)

Replies

Apple provides the following Methods by default:

In addition to these, can I get other file events like: Rename, Delete, Create, Move etc. on finder.

These are very different things. The first set is the system telling you that someone is observing the directory, and thus it makes sense to work harder to sync it (typically with a remote server). The second set is about observing file system changes. The Finder Sync infrastructure does not provide any specific facility for this, but macOS has a bunch of general-purpose facilities that you can use, including:

  • FSEvents

  • kqueues

  • file coordination

Share and Enjoy

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

let myEmail = "eskimo" + "1" + "@apple.com"