Objective-C在performSelectorOnMainThread中传递带参数的消息:
当传递给@selector的方法有参数时,需要有关语法的帮助。谢谢Objective-C在performSelectorOnMainThread中传递带参数的消息:,objective-c,ios5,objective-c-blocks,performselector,Objective C,Ios5,Objective C Blocks,Performselector,当传递给@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? //Thi
//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];
});
提示:这就是为什么有“withObject:”部分
提示2:苹果的框架有相当好的文档
提示3:
[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];
搜索该方法并阅读文档。
[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];