-3

当传递给 @selector 的方法有参数时,需要语法帮助。谢谢!

//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];
  });
4

2 回答 2

3

提示:这就是“withObject:”部分存在的原因。

提示 2:Apple 为他们的框架提供了非常好的文档。

提示 3:

[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];
于 2012-08-14T17:37:33.880 回答
1
[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];
于 2012-08-14T17:37:30.957 回答