i'm working on a iOS5+ project (xcode 4.4.1 SDK 5.1)
i have this code inside a unit test:
[_appDelegate application:nil didFinishLaunchingWithOptions:nil];
UITabBarController *tabBarController = (UITabBarController*)_appDelegate.window.rootViewController;
NSArray *viewControllers = [tabBarController viewControllers];
UINavigationController *nc_1 = [viewControllers objectAtIndex:0];
UIViewController *vc_1 = nc_1.topViewController;
STAssertTrue([vc_1 isKindOfClass:[ScheduleViewController class]]==YES, @"UITabBarController first tab should be a ScheduleViewController class");
If i run the test, the test fail.
So i check with the debugger:
(lldb) po [ScheduleViewController class]
(id) $1 = 0x00142b04 ScheduleViewController
(lldb) po vc_1
(UIViewController *) $2 = 0x11a32dc0 <ScheduleViewController: 0x11a32dc0>
(lldb) print (BOOL) [vc_1 isKindOfClass:(Class)[ScheduleViewController class]]
(BOOL) $4 = YES
(lldb) po [vc_1 class]
(id) $5 = 0x00142b04 ScheduleViewController
(lldb)
In application:didFinishLaunchingWithOptions: i create a ScheduleViewController and i use it as rootController of the navigation controller. The debugger say it's correct. I don't understand what is wrong with the assert above.
Someone have idea about this?
Update
The first implementation of thE assert was:
STAssertTrue([vc_1 isKindOfClass:[ScheduleViewController class]], @"UITabBarController first tab should be a ScheduleViewController class");
The assert failed at the same way.
Update 2
As suggested in the comment i try to add this piece of code before the assert:
BOOL vcBool = [vc_1 isKindOfClass:[ScheduleViewController class]];
With the debugger i see:
(lldb) print (BOOL) [vc_1 isKindOfClass:(Class)[ScheduleViewController class]]
(BOOL) $1 = YES
(lldb) print (BOOL) vcBool
(BOOL) $2 = NO
(lldb)
Update 3
I added this line, as suggested in the comments, before the assert:
NSLog(@"vc_1=%@ class=%@", vc_1, NSStringFromClass([vc_1 class]));
From the debug console:
vc_1=<ScheduleViewController: 0x993bdb0> class=ScheduleViewController