首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关闭UIDocument后停止自动保存

关闭UIDocument后停止自动保存
EN

Stack Overflow用户
提问于 2011-12-16 08:50:11
回答 1查看 479关注 0票数 1

创建了UIDocument(XDocument)的一个子类,由于数据量大,保存文档需要一些时间。

因此,当我使用closewithcompletionhandler关闭XDocument实例时,它被成功关闭并返回到成功块,但一段时间后,观察到文档成功关闭后调用了autosavewithcompletionHandler。在关闭文档之前,我是否缺少任何参数?在关闭UIDocument子类之前需要采取哪些预防措施?

感谢您的帮助和感谢。

EN

回答 1

Stack Overflow用户

发布于 2012-01-08 02:22:01

我不知道这是否是最好的答案,但我最终做的是关闭文档,然后在完成处理程序中删除它。类似于:

代码语言:javascript
复制
NSURL *url = _document.fileURL;
[_document closeWithCompletionHandler:^(BOOL success) {
    if (success) {
        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
            NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:nil];
            [coordinator coordinateWritingItemAtURL:url options:NSFileCoordinatorWritingForDeleting error:NULL byAccessor:^(NSURL *newURL) {
                [[NSFileManager defaultManager] removeItemAtURL:newURL error:NULL];
            }];
        });
    }
}];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8528592

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档