Search code examples
objective-cmacoscocoansurlnsfilemanager

Cocoa URL bookmark triggered by events


Is it possible to listen to some notification that triggers upon file modification, such as rename or move?

Currently, I created a bookmark to a file, stored its last modified date (thanks to this great post: Keep a reference to a file after it has moved in objective-c?), and then my application sets a timer that compares the bookmark's URL's last modified date, and acts upon changes.

My question is - is it possible to listen to some event, perhaps some mechanism similar to NSWorkspaceDidPerformFileOperationNotification, in order to monitor my directory's modifications, instead of using a timer?

Thanks, Nili


Solution

  • There are several ways to accomplish your goal:

    To watch a single file, you'll probably be most happy with NSFileCoordinator.