objective c - How to determine when all methods are finished? -


i have rootviewcontroller create mainviewdownload instance , call method of instance.

mainviewdownload *download = [[mainviewdownload alloc] init]; [download loadmainviewimages]; 

how can know when loadmainviewimages finished ? call loadmainviewimages rootviewcontroller loadmainviewimages calls method inside mainviewdownload class (lets method2), , method2 calls again method3. so, there way know when loadmainviewimages finished (actually when method3 finished since last called).

if you're not multithreading, i.e. starting method runs on separate thread loadmainviewimages, methods executed sequentially. once loadmainviewimages returns can sure "in it" executed. how methods work.

edit better formatting of comments:

mainviewdownload.h

@protocol mainviewdownloaddelegate;  @interface mainviewdownload @property (nonatomic, weak) nsobject<mainviewdownloaddelegate> *delegate; @end  @protocol mainviewdownloaddelegate - (void)downloaddidfinish:(mainviewdownload *)download; @end 

mainviewdownload.m

@implementation mainviewdownload  - (void)somemethodthatdownloadsstuff_oriscalledafterthedownload {     ...     if ([self.delegate respondstoselector:@selector(downloaddidfinish:)]) {         [self.delegate downloaddidfinish:self];     } }  @end 

rootviewcontroller.h

@interface rootviewcontroller <mainviewdownloaddelegate> ... @end 

rootviewcontroller.m

@implementation ... - (void)downloaddidfinish:(mainviewdownload *)download {     // hide download view here. } @end 

make sure set delegate of download view root view controller.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -