ios - How to reload a data table from a Controller? (I'm using Core Data) -


i developing ios app. trying fetch data table after insert data on table. code:

- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {   notification *notification = [self.fetchedresultscontroller objectatindexpath:indexpath];    if ([notification.isread isequaltonumber:@no]) {     [self sendnotificationdata:notification];     notification.isread = @yes;   }    [self insertpost:notification.notificatableid];    post *post = [self fetchobjectfrom:@"post"                        withpredicate:[nspredicate predicatewithformat:@"objectid == %@", notification.notificatableid]]; }  - (void)insertpost:(nsstring *)postid {    nsdictionary *parameters = [[nsdictionary alloc] initwithobjectsandkeys:postid, @"notification[post_id]", nil];    [[akdemiaapiclient sharedclient] post:[nsstring stringwithformat:@"/notifications/%@/get_post",postid] parameters:parameters                             success:^(nsurlsessiondatatask *task, id json) {                                [[nsuserdefaults standarduserdefaults] setbool:yes                                                                       forkey:@"postnotificationsdetailsnotificationname"];                               [[nsuserdefaults standarduserdefaults] synchronize];                                [[nsnotificationcenter defaultcenter] postnotificationname:@"postnotificationsdetailssucceednotificationname"                                                                                   object:nil];                                akdemiasyncengine *syncengine = [[akdemiasyncengine alloc] init];                               [syncengine processjsondatarecordsintocoredata:json forcomponent:kfeed];                                [[akdemiacoredatacontroller sharedinstance] savebackgroundcontext];                               [[akdemiacoredatacontroller sharedinstance] savemastercontext];                              } failure:^(nsurlsessiondatatask *task, nserror *error) {                                [[nsnotificationcenter defaultcenter] postnotificationname:@"postnotificationsdetailserrornotificationname"                                                                                   object:nil];                              }]; } 

the problem when select notification , try fetch post after insert, because seems isn't on table, if refresh controller , select same notification post exists , ok.

i trying find like:

[tableview reloaddata] 

but works on request instead of table.

you should implement nsfetchedresultscontroller delegate methods. in callback api call can insert retrieved items in core data , save. delegate methods should called , insert / update / delete table view cells based on indexpath. there reference implementation in xcode template (master-detail, check core data).


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -