Obj-C:FSEvent 在每次启动应用程序时报告相同的事件
我设置了一个运行良好的 FSEvent,但每次启动应用程序时它都会报告相同的事件。
例如:
我的 FSEvent 监视器目录是:
Test/
...并且有三个文件:
test1, test2, test3
但是,在我删除 FSEvent 目录中的 test1
后,它一直告诉我 test1
已被删除每次运行程序时都会删除,而不是删除后一次。
我清理了上下文中的所有托管对象并删除了整个目录,但该事件不断被报告。
我应该怎么做才能让它只在删除后立即告诉我,然后再也不会告诉我?
多谢!
I setup a FSEvent that runs well but it keeps reporting the same event each time I launch the app.
Ex:
My FSEvent monitor directory is:
Test/
...and there are three files:
test1, test2, test3
However, after I deleted test1
in my FSEvent Directory, it keeps telling me that test1
has been deleted every time I run the program instead of just the one time after the deletion.
I cleaned all managedObjects in my context and deleted the whole directory but the event keeps being reported.
What should I do such that it only tells me right after the deletion and then never again?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
文件系统事件在启动之间保持不变。它们由文件系统本身而不是应用程序跟踪。这就是为什么您每次启动时都会看到该事件。
我相信您必须调用FSEventsPurgeEventsForDeviceUpToEventId
或类似的方法来清除事件。对此持保留态度。我没怎么摆弄它。
编辑:
来自 文件系统事件编程指南:
我认为要记住的重要一点是,文件系统事件实际上并未存储,甚至与正在观察它们的应用程序无关。它们独立于文件系统本身中的应用程序而存在。在实践中,可以设置多个不同的应用程序来观察同一事件。
File system event are persistent between launches. They are tracked by the file system itself, not the app. That is why you keep seeing the event every time you launch.
I believe you have to callFSEventsPurgeEventsForDeviceUpToEventId
or the like to clear the events.Take that with a grain of salt. I haven't fiddled with it much.
Edit:
From File System Events Programming Guide:
I think the important thing to remember is that the file system events are not actually stored or even related to app that is observing them. They exist independently of the app in the file system itself. In practice, several different apps could be set to observe the same event.