this question has answer here:
- async call objective c iphone 4 answers
i have 2 function first in 1 calls & other in class.i have first function defined in other class.i calling function in other class.i have second function defined in own class.
firstclass.m has firstfunction function & calling in secondclass.m.
secondclass.m has secondfuncion function & calling in secondclass.m.first function fetch data server using afnetworking & give response. of calling functions in secondclass.m
secondclass *sec = [[secondclass alloc]init]; [sec firstfunction]; [self secondfunction];
i want call second function when working of first s completed.but here first function asynchronous second function not wait response of first function.please tell how can this?can use kind of listener code should not proceed ahead should wait response first function.
------define own completion block.
typedef void(^mycompletion)(bool);
------create method takes completion block parameter.
-(void) mymethod:(mycompletion) compblock { //do stuff compblock(yes); }
-----this how use it.
[self mymethod:^(bool finished) { if(finished) { nslog(@"function execute successfully"); //call second method here } }];
Comments
Post a Comment