views:

44

answers:

3
- (void)applicationDidFinishLaunching:(UIApplication *)application {    

    // Create the data controller.
    DataController *controller = [[DataController alloc] init];
    self.dataController = controller;


    [controller release];

    rootViewController.dataController = dataController;


    // Override point for customization after app launch    
    [window addSubview:[navigationController view]];
    [window makeKeyAndVisible];
}

In my application, I found the rootViewController.dataController = dataController; did not work. And I setted a break point at the @synthesize dataController, found @synthesize dataController was not invoked.

What's wrong with my code.

I compare all my code with the SimpleDrillDownApp (an example from Apple), they are almost the same. Why my application did not work! The compile was passed. But it did not work right.

Anyone could help me?

A: 

you wont see the synthesize call being invoked, synthesize just generates getters and setters for your property, how are you declaring the property? When you say it does not work what do you mean? From the code above i dont see where you initialized the rootViewController, is it set through a nib? If so maybe you set it wrong and rootViewController is nil...

Daniel
A sample of the application delegate header file would probably be good info to have too.
criscokid
yes indeed
Daniel
Actually, you can set a breakpoint on the @synthesize line and the debugger will break in the setter/getter. (This may be new to Snow Leopard).
bbum
never tried it, perhaps im wrong, if thats the fact then root view controller is not instantiated when the asker i s doing the assignment
Daniel
+1  A: 

Without seeing your code, the most obvious conclusion is that rootViewController is nil and, thus, rootViewController.dataController = dataController; does nothing because Objective-C treats messages to nil as a no-op.

So, check to make sure rootViewController is not nil before you do anything else.

bbum
You are right. rootViewController is nil. The rootViewController was not initialized. Ha ha. Thank you very much!!!
A: 

dataController is a simple ivar access.

self.dataController will go through the getter, no?

Steve Riggins