iOS5 文件共享:识别文件何时添加到目录?

发布于 2024-12-09 23:41:24 字数 398 浏览 1 评论 0原文

正如标题所说,我想知道如何识别新文件已添加到我的应用程序中,例如通过 iTunes 同步。在 iOS4 中,我使用了方法

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

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

但从 iOS 5 开始,这就没用了,因为应用程序不会进入后台并在同步后变为活动状态。它保持活跃。那么有没有办法解决这个问题呢?

问候

拉尔夫

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

顾挽 2024-12-16 23:41:24

如果 iTunes 文件共享使用新的文件协调机制(尚未检查,但我假设它确实如此),您可以实现 NSFilePresenter 协议来获取文档目录中的更改通知。

通过实现 presentedSubitemDidAppearAtURL: 和相关方法,应该可以对整个目录使用单个文件呈现器(请参阅 NSFilePresenter 文档)。

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).

百善笑为先 2024-12-16 23:41:24

通常我会创建一个计时器并定期检查与 iTunes 共享的目录中是否有新文件。我认为对于 iOS5 这是最好的方法。

iOS5 可以通过 WiFi 同步,因此您无法控制何时将文件添加到目录中

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文