4

as the title says i wanna know how i can recognize that new file have been added to my App for example over an iTunes Sync. In iOS4 i used the methods

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

or

- (void)application:(UIApplication *)application didBecomeActive

But since iOS 5, this is useless because the app will not enter the Background and become active after a sync. It stays active. So is there a way to solve this?

regards

Ralf

Rale Kay
  • 51
  • 4

2 Answers2

2

If iTunes file sharing uses the new file coordination mechanism (haven't checked but I would assume that it does), you could implement the NSFilePresenter protocol to get notified of changes in the Documents directory.

It should be possible to use a single file presenter for the entire directory by implementing presentedSubitemDidAppearAtURL: and related methods (see "Handling Changes to a Presented Directory" in the NSFilePresenter documentation).

omz
  • 53,243
  • 5
  • 129
  • 141
  • -.- Ok. Shame on me that i didn´t see that in the Doc. Sounds great. Thanks omz – Rale Kay Oct 15 '11 at 11:52
  • @RaleKay Did you ever get to try this? I just attempted to implement my suggestion and while it works fine in the simulator when I drop files into the simulator's Documents directory, I don't get any notifications on the device when I use iTunes file sharing. Not sure if I'm doing something wrong or if iTunes just doesn't use file coordination (in which case it might be worth filing a bug). – omz Oct 26 '11 at 13:39
  • From [this thread](https://devforums.apple.com/message/517775) in the dev forums, it seems that iTunes really doesn't use file coordination. :( – omz Oct 26 '11 at 13:42
  • Hi. Sorry for my late respond. Jap i did get it to work but without the protocol. I just did start a request if there are any new files in the documents directory in a background thread. It´s exactly the the same as the protocol should work. But without the protocol you got it for pre iOS5 Devices, too ;) – Rale Kay Dec 15 '11 at 09:20
0

Usually I create a Timer and periodically check for new files in the Directory shared with ITunes. I think with iOS5 it's the best approach.

iOS5 can sync through WiFi so you don't have control about when a file will be added to the directory

ppaulojr
  • 3,579
  • 4
  • 29
  • 56