我有一个本地UIDocument,其中包含最近查看文章保存到单个文件的NSArray。
我的应用程序是基于UITabbarController的,在一个选项卡中有从互联网上获取的文章列表,另一个是与此UIDocument支持的UITableView。一切加载都很好,问题是UIDocument在打开后没有更新。当我使用核心数据和NSFetchedResultController时,它可以与这些controllerWillChangeContent无缝地工作。有没有类似的UIDocument版本?
发布于 2013-01-10 07:56:14
UIDocument为此提供了updateChangeCount。在您做了更改之后,将其发送到您的UIDocument (子类),或者让UIDocument侦听从适当设置了选择器的视图控制器发送的通知。
例如,在UIDocument类的初始化中:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(somethingChanged) name:@"DocumentDidChangeNotification" object:nil];
同样在UIDocument中:
- (void)somethingChanged { [self updateChangeCount:UIDocumentChangeDone]; }
在视图控制器中,当内容发生变化时,执行以下操作:
[[NSNotificationCenter defaultCenter] postNotificationName:@"DocumentDidChangeNotification" object:nil];
https://stackoverflow.com/questions/14243459
复制相似问题