Search code examples
iositunes

Can iOS file system changes be observed from files being uploaded through iTunes?


I have an application that displays a list of files to the user. The application has file sharing enabled, so the user can add or remove files through iTunes.

Is it possible to observe file system changes from the user doing this? I'd like to automatically update the display of files available.


Solution

  • Unfortunately there is no observer or notification for such event, but instead you can rescan the files in the applicationDidBecomeActive: method of your application's delegate.

    Workflow: when the user adds files in your app's Document directory thru iTunes, iTunes briefly synchronize the files, making your app become inactive (applicationWillResignActive:) during this small duration, and then make it active again (applicationDidBecomeActive:).

    Thus (and even if it is not the only time this method is called) scanning the contents of your Documents folder in this method guaranties that it will be up to date when the user adds files thru iTunes.


    For more info about UIApplication's Delegate Messaging workflow, I encourage you to read this excellent article from cocoanetics.