Frage

Need help with the syntax when the method being passed into @selector has arguments. Thanks!

//This works
dispatch_async(kBgQueue, ^{ 

 [self performSelectorOnMainThread:@selector(hydrateList) withObject:nil waitUntilDone:YES];   

});



//But what about when the method in the selector has arguments?
//This is incorrect, syntactically
  dispatch_async(kBgQueue, ^{ 

     [self performSelectorOnMainThread:@selector(hydrateListForCategory:self.categorySelected) withObject:nil waitUntilDone:YES];
  });
War es hilfreich?

Lösung

[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];

Andere Tipps

Hint: that's why the "withObject:" part is there.

Hint 2: Apple has pretty good docs for their frameworks.

Hint 3:

[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top