Question

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 ?

Was it helpful?

Solution

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];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top