ios - Refresh UITableView with iCloud changes -


i have app have intergrated core data icloud. have following notifications in view controller.

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(reloadfetchedresults:) name:nspersistentstorecoordinatorstoresdidchangenotification object:coredatacontroller.psc];  [[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(reloadfetchedresults:) name:nspersistentstoredidimportubiquitouscontentchangesnotification object:coredatacontroller.psc]; 

the view controller contains uitableview loaded core data using nsfetchedresultscontroller. unsure put in following method (called notifications above) refresh table. have tried reloading table, , refetching data no avail. know icloud doing job because if reload viewcontroller changed data shows.

- (void)reloadfetchedresults:(nsnotification*)note {     nslog(@"underlying data changed ... refreshing!");      //_fetchedresultscontroller=nil;     //[self fetchedresultscontroller];      [thetableview reloaddata];   } 

any appreciated, thanks!

do need fetch set of data, or looking see changes same results set? if former, tear down , rebuild new predicate, fetch, etc. , perform fetch.

if latter, need merge changes in moc. when register notifications, set this:

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(documentcontentsimportedchanges:) name:nspersistentstoredidimportubiquitouscontentchangesnotification object:self.managedobjectcontext.persistentstorecoordinator];   - (void) documentcontentsimportedchanges:(nsnotification*)notification {     // received updates icloud     [self.managedobjectcontext mergechangesfromcontextdidsavenotification:notification]; } 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -