objective c - NSOperationQueue finished wont start new method -


when observer tells me there no more operations, function not called (performselector...). funny thing nslog(@"queue has completed") logged correctly.

- (void) observevalueforkeypath:(nsstring *)keypath ofobject:(id)object                      change:(nsdictionary *)change context:(void *)context { if (object == self.operationqueue && [keypath isequaltostring:@"operations"]) {     if ([self.operationqueue.operations count] == 0)     {         [self performselector:@selector(refreshcollectionview) withobject:nil afterdelay:0.2];         // here when queue has completed         nslog(@"queue has completed");      } } else {     [super observevalueforkeypath:keypath ofobject:object                            change:change context:context]; } } 

edit

got it:

dispatch_async(dispatch_get_main_queue(), ^{              [self performselector:@selector(refreshcollectionview) withobject:nil afterdelay:0.2];              }); 

dunno why performselectoronmainthread... didnt work works way.

if observer being fired on same thread queue, quite queue's thread being reaped upon completion. since -performselector:...afterdelay: requires running run loop, dropped on floor.

since updating ui anyway, perform selector on main thread.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -