View Controller が AppDelegate のプロパティである場合、コード リファレンスと同様
@interface AppDelegate_Shared : NSObject <UIApplicationDelegate, UIAlertViewDelegate, OMFDataLoadDelegate> {
NSManagedObjectModel *managedObjectModel;
NSManagedObjectContext *managedObjectContext;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
UIWindow *window;
UITabBarController *tabBarController;
}
次に、割り当て時に AppDelegate によって割り当てられている可能性があります。Apple のドキュメントによると、ビューがメモリにロードされた後に viewDidLoad が実行されますが、これは少し混乱する可能性があります。
http://developer.apple.com/iphone/library/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW25
期待した結果を得るには、NSLog ステートメントを viewDidAppear に移動します。ステートメントがロードされると予想される方法を示す 2 つのサンプル スニペットを次に示します。
ViewController.m
- (void) viewDidLoad {
NSLog(@"1st - this occurs when appDelegate allocates this object");
}
- (void) viewDidAppear {
NSLog(@"3rd - this should appear after the applicationDidFinishLaunchingStatement");
}
AppDelegate_Shared.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSLog(@"2. Starting AppDelegate_Shared");
[window addSubview:self.tabBarController.view];
[window makeKeyAndVisible];
NSLog(@"4. Leaving AppDelegate_Shared");
return YES;
}