Search code examples
iphoneiosxcodensfilemanager

NSFileManager watch directory


How would you monitor a directory with NSFileManager?

I would like to able to detect when a file is deleted/added in my documents directory while my app is running.


Solution

  • Look Kernel Queues: An Alternative to File System Events in Apple documentation. There is an example for iOS in AVPlayerDemo (look DirectoryWatcher class).

    Also, check Directory Monitor blog post.