First off, I asked this question in a different way yesterday. After more experimenting I'm still unclear as to the "WHY." I understand what I need to do but want to get clear on what's happening. Here's the scenario…
I'm starting with a clean slate, a single view application and simply adding the following NSLog to the appDelegate …
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSLog(@"%@",[self.window.rootViewController description]);
return YES;
}
The above returns
<ViewController: 0x17e7dbf0>
Now, when I create a new class named "TestViewController" (of type UIViewController) and assign it to the controller in my storyboard, the above NSLog returns
<TestViewController: 0x146594c0>
So, my question is, "If the previous description shows the rootViewController to be of type "TestViewController, why do I need to typecast (TestViewController *)? Why can't I do this…
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
TestViewController *tvc = self.window.rootViewController;
return YES;
}
instead of...
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
TestViewController *tvc = (TestViewController*)self.window.rootViewController;
return YES;
}
I'd like to clear up the fog here. What piece of the puzzle am I missing?
Thanks for your help!