objective c - iPhone SDK Background threads calling other methods -
i seemingly straightforward question can't seem find answer (and hindering app).
i have background thread running paricular method:
-(void)processimage:(uiimage *)image { nsautoreleasepool * pool = [[nsautoreleasepool alloc] init]; //process image here in background here [pool drain]; }
this works great, question comes when want call method inside already-background method. call stay in background? need add nsautoreleasepool * pool = [[nsautoreleasepool alloc] init];
, [pool drain];
new method make run in background well?
any advice helpful. bit confused this.
many thanks, brett
it stay in background, on same thread called from.
some threading notes consider this:
- it may not obvious, if call timer background thread, , thread exits before timer supposed go off, timer not called. recommended setup timers main thread
- you dont need autorelease pool unless spawn thread.
- any ui updates should done on main thread
Comments
Post a Comment