首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >UIDocumentStateChangedNotification检测删除项目

UIDocumentStateChangedNotification检测删除项目
EN

Stack Overflow用户
提问于 2013-10-12 01:20:09
回答 1查看 382关注 0票数 0

我想知道是否可以使用UIDocumentStateChangedNotification检测项目是否被删除,如果没有,我如何检测项目是否从云中删除?

EN

回答 1

Stack Overflow用户

发布于 2014-06-25 17:33:56

在您的viewDidLoad中添加UIDocumentStateChangedNotification的观察者。

代码语言:javascript
运行
复制
[[NSNotificationCenter defaultCenter]
        addObserver:self
        selector:@selector(itemHasChanged:)
        name:UIDocumentStateChangedNotification
        object:nil];

如果已更改对象的documentState设置为UIDocumentStateSavingError,则该对象已被删除。

代码语言:javascript
运行
复制
-(void) itemHasChanged:(id)sender {
    UIDocument *itemDoc = [sender object]; 

    if ([itemDoc documentState] == UIDocumentStateSavingError) {
      // your code to handle a deleted document goes here
      // in my case I remove that object from my array of current objects.
    }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19323827

复制
相关文章

相似问题

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