Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective-C在performSelectorOnMainThread中传递带参数的消息:_Objective C_Ios5_Objective C Blocks_Performselector - Fatal编程技术网

Objective-C在performSelectorOnMainThread中传递带参数的消息:

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

当传递给@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];
  });
提示:这就是为什么有“withObject:”部分

提示2:苹果的框架有相当好的文档

提示3:

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

搜索该方法并阅读文档。
[self performSelectorOnMainThread:@selector(hydrateListForCategory:) withObject:self.categorySelected waitUntilDone:YES];