开发者

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 upd开发者_StackOverflow中文版ate the display of files available.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜