我有一个符合NSFilePresenter协议的对象,它表示我的基于文档的应用程序文档包。当在包内创建一个新文件时,使用带有正确NSFileCoordination方法的NSFileManager或者通过Finder i只能得到 -presentedSubitemDidChangeAtURL:事件,但在这种情况下似乎不那么明显 -presentedSubitemDidAppearAtURL:。
I have an object which conforms to NSFilePresenter protocol that represents my document-based application document package. When a new file is created inside the package, either programmatically using NSFileManager with proper NSFileCoordination methods or via Finder i only got -presentedSubitemDidChangeAtURL: event, but not seeming so obvious in this case -presentedSubitemDidAppearAtURL:.
这是一个预期的行为还是我做错了?
Is this an expected behavior or i am doing something wrong?
在NSFilePresenter状态中 -presentedSubitemDidAppearAtURL:的注释:
The comments on -presentedSubitemDidAppearAtURL: in NSFilePresenter state it clear:
通知目录中包含的文件或目录已添加。如果这个方法没有实现,但 -presentedItemDidChange 是,并且该目录实际上是一个文件包,那么文件协调机制将调用 -presentedItemDidChange 。
Be notified that a file or directory contained by the directory has been added. If this method is not implemented but -presentedItemDidChange is, and the directory is actually a file package, then the file coordination machinery will invoke -presentedItemDidChange instead.
推荐答案
,我打开了一个与苹果的技术支持问题。他们的回答是,这是一个错误,我们现在唯一能做的就是通过 -presentedSubitemDidChangeAtURL:。
After struggling with this exact issue for quite a while, I opened a technical support issue with Apple. Their response was that this is a bug, and the only thing we can do right now is to do everything through -presentedSubitemDidChangeAtURL:.
我鼓励任何遇到此问题的人提出错误( bugreport.apple ),鼓励苹果以尽快解决此问题。
I would encourage anyone encountering this issue to file a bug (bugreport.apple) to encourage Apple to get this problem fixed as soon as possible.
更多推荐
NSFilePresenter
发布评论