So I have an instance of MyViewController in the detail view of a UISplitViewController. I am running a unit test to see whether the detail view contains the correct type of view.
I test the type of controller in the unit test with the following:
[controller isKindOfClass:[MyViewController class]];
However, the isKindOfClass method always returns NO
When I po the object in the debugger I get the following:
(gdb) po controller
<MyViewController: 0xb31c4d0>
I have also tried the isMemberOfClass: method, it yields the same results. Can anyone explain why this would happen?
EDIT: So after reading the article posted by Nick Weaver I realised that I was including my app's source files in the test bundle's compile sources build phase. This was also indicated in the log by statements similar to following:
Class MyViewController is implemented in both /Users/jdoe/Library/Application Support/iPhone Simulator/4.3.2/Applications/670A077A-BAD8-4FA6-945A-851F33114CF5/MyApp.app/MyApp and /Users/jdoe/Library/Developer/Xcode/DerivedData/MyApp-drxyfejeattjwgantzesgensnlnx/Build/Products/Debug-iphonesimulator/MyAppTests.octest/MyAppTests. One of the two will be used. Which one is undefined.
However, when I remove the source files from the test bundle's compile sources build phase, I would get a linker error that looks like the following:
Undefined symbols for architecture i386:
"_OBJC_CLASS_$_MyViewController", referenced from:
objc-class-ref in _MyViewControllerTests.o
(maybe you meant: _OBJC_CLASS_$__MyViewControllerTests)