isMemberOfClass returns no when ViewController is instantiated from UIStoryboard

孤街醉人 提交于 2019-11-27 09:09:48

The problem is likely that your view controller's .m file is included in both targets, the app and the test bundle. ocunit (and derivatives like Kiwi) uses a test harness that makes the classes included in the app available to tests without having to explicitly include their implementation.

Including both has given you two copies of the same class, which is why they have the same description but different memory addresses.

You generally want isKindOfClass: and not isMemberOfClass:. The difference is that isKindOfClass: will return YES if the receiver is a member of a subclass of the class in question, whereas isMemberOfClass: will return NO in the same case.

You could also directly compare the classes using [self.testController class] == [PatientTestViewController class].

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!