iphone - how to wait until method containing block get executed -


i in situation need wait until method executed , execution move ahead have tried cfrunlooprun ,

  dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_high, 0);       dispatch_async(queue, ^{               [eventstore requestaccesstoentitytype:ekentitytypeevent completion:^(bool granted, nserror *error)      { 

but did not helped me code below

- (nsarray*) calendarmonthview:(tkcalendarmonthview*)monthview marksfromdate:(nsdate*)startdate       todate:(nsdate*)lastdate{          [self fatchallevent];// method contain block takes 1 second executed , events array filled block          nslog(@"all event %@",events); shows null here cuse blocked has not executed yet          [self generaterandomdataforstartdate:startdate enddate:lastdate]; method need events array there no data nothing happens            return self.dataarray;      } 

how can wait until fatchallevent method executed , after execution processed

dispatch_queue_t queue = dispatch_get_global_queue(dispatch_queue_priority_default, 0); dispatch_group_t group = dispatch_group_create();  // add task group dispatch_group_async(group, queue, ^{     [self method1:a]; });  // add task group dispatch_group_async(group, queue, ^{     [self method2:a]; });  // add handler function when entire group completes // it's possible happen if other methods have finished dispatch_group_notify(group, queue, ^{      [self methodfinish] });  dispatch groups arc managed. retained system until of blocks run, memory management easy under arc.  see dispatch_group_wait() if want block execution until group finishes. 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -