开发者

iPhone File Sharing: How to recognize when files have been added?

I have file sharing via iTunes working in my application (reference What's New in iOS 3.2) by enabling the UIFileSharingEnabled key, but according to the documentation:

"Applications that support file sharing should be able to recognize when files have been added to the Documents directory and respond appropriately开发者_开发问答."

My question is, if my application is running, and then the user decides to add a file, how do I respond to this event? And what event is it that I would respond?

In other words, I know what my iPhone application needs to do when a file is added but not sure where to put this "responding" code. Currently, if my application is running (could be running in the background as well) and a file is added, the only way to see the effects of this added file is by force-quitting the application and then re-launching the app.


You need to remember that your app isn't really running in the background, or at all for that matter when files are added to the device. In order for the user to add files to device he needs to sync it in iTunes. So after the sync is done, your app will either be relaunched, or resumed, in both these cases you have methods in your app delegate which you can use to check if new files were added to to the application.

- (void)applicationDidBecomeActive:(UIApplication *)application
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜