views:

52

answers:

1

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.

A: 

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
Ron Srebro
Thanks Ron. This is exactly what I was looking for. In hindsight, kind of obvious.
kanso
You're welcome, in hindsight lots of things are obvious. It always helps to go through your issues through more people. Cheers
Ron Srebro