I have one local UIDocument that contain save NSArray of recently views articles into single file.

My app is UITabbarController based, In one tab there is list of fetched articles from internet, the other one is UITableView backed with this UIDocument. Everything load just fine the problem is UIDocument didn't update once it has open. When I use Core data and NSFetchedResultController it work seamlessly with those controllerWillChangeContent. Is there any similar one for UIDocument ?

有帮助吗?

解决方案

UIDocument provides updateChangeCount for this. Send this to your UIDocument (subclass) after you made a change or let the UIDocument listen to notifications sent from viewcontrollers with the selector set appropriately .

E.g. in the init of your UIDocument class:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(somethingChanged) name:@"DocumentDidChangeNotification" object:nil];

Also in UIDocument:

- (void)somethingChanged { [self updateChangeCount:UIDocumentChangeDone]; }

And in a view controller, when the content changed, do:

[[NSNotificationCenter defaultCenter] postNotificationName:@"DocumentDidChangeNotification" object:nil];

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top