简体   繁体   English

performSelector在单元测试Objective-C中不起作用

[英]performSelector not working in unit test Objective-C

I am trying to make a unit test for my application but performSelector doesn't work. 我正在尝试为我的应用程序进行单元测试,但是performSelector无法正常工作。 I've tried 我试过了

[self performSelector:@selector(checkIDs:) withObject:nil];

and performSelectorOnMainThread but for some reason the method doesn't get called. 和performSelectorOnMainThread,但是由于某种原因,该方法未得到调用。

 [self checkIDs:nil] 

seems to work fine but performSelector doesn't. 似乎工作正常,但是performSelector却不能。 Getting this method to get called is not my main concern. 我最关心的不是获取此方法来调用。 The reason for me asking is because I have a bigger problem but I think the reason is because performSelector isn't working. 我问的原因是因为我有一个更大的问题,但我认为原因是因为performSelector无法正常工作。

Am I missing something? 我想念什么吗? Once again, this is for a Unit Test. 再次,这是用于单元测试。 Thanks! 谢谢!

dispatch_async(dispatch_get_main_queue(), ^{
  [self checkIDs:nil];
});

Try this it should work. 试试这个,它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM