iphone - iOS detachNewThreadSelector leaking -


i have uiscrollview loading images in. apply effect image , takes bit pre-loading decided on different thread using detachnewthreadselector. using ktphotobrowser on github this.

so basically, have function so.

- (void)setcurrentindex:(nsnumber *)newindex {     nsautoreleasepool *pool = [[nsautoreleasepool alloc] init];     currentindex_ = [newindex integervalue];     [self loadphoto:currentindex_];    [self loadphoto:currentindex_ + 1];    [self loadphoto:currentindex_ - 1];    [self unloadphoto:currentindex_ + 2];    [self unloadphoto:currentindex_ - 2];    [self settitlewithcurrentphotoindex];   [self togglenavbuttons];   [pool release];  } 

i call using

[nsthread detachnewthreadselector:@selector(setcurrentindex:) totarget:self withobject:[nsnumber numberwithint:5]]; 

when run this, appears throwing leak. beginning wonder if should putting autorelease pool around code in loadphoto method. if curious code, have included below.

- (void)loadphoto:(nsinteger)index {    if (index < 0 || index >= photocount_) {       return;    }     id currentphotoview = [photoviews_ objectatindex:index];    if (no == [currentphotoview iskindofclass:[ktphotoview class]]) {       // load photo view.       cgrect frame = [self frameforpageatindex:index];       ktphotoview *photoview = [[ktphotoview alloc] initwithframe:frame];       [photoview setscroller:self];       [photoview setindex:index];       [photoview setbackgroundcolor:[uicolor clearcolor]];        // set photo image.       if (datasource_) {          if ([datasource_ respondstoselector:@selector(imageatindex:photoview:)] ==    no) {             uiimage *image = [datasource_ imageatindex:index];             [photoview setimage:image];          } else {         [datasource_ imageatindex:index photoview:photoview];          }       }        [scrollview_ addsubview:photoview];       [photoviews_ replaceobjectatindex:index withobject:photoview];       [photoview release];    } else {       // turn off zooming.       [currentphotoview turnoffzoom];    } } 

any ideas appreciated.

your code seems ok using uikit thread. uikit classes should used application’s main thread.

uikit framework reference introduction


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -