ios - Objective-c : Execute a function in current class only after NSURLSession and NSXMLParser delegates complete in another class -
i have class1 in have load uitableview row on didselectrowatindexpath. in didselectrowatindexpath make call method in class2 thereby calls nsurlsession delegates , nsxmlparser delegates. want value of parsed data , reload uitableview row in class1.
i want reload uitableview after data. delegate methods asynchronous not able data , empty uitableview row.
what can solution?
on completion of data pulling , parsing in class2, let class1 know:
[[nsnotificationcenter defaultcenter] postnotificationname:@"kdataisready" object:@{@"key":@"value"}]; you need register class1 listener on (e.g. in viewdidload):
[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(dataready:) name:@"kdataisready" object:nil]; which calls method in class1:
-(void)dataready:(nsnotification *)n { nsdictionary * d = n.object; nsstring * value = d[@"key"]; //e.g. update data array, refresh tableview / specific cell }
Comments
Post a Comment