Objective c 目标C基本问题
我使用基于视图的模板制作了一个简单的应用程序。我只在viewController文件中的view didload方法中放入了nslog,也在applicationDidFinishLaunch方法(在appDelegate中)中放入了nslog,以检查首先调用哪个类文件 运行之后,我得到了:viewController先运行,然后是appdelegate..但我认为appdelegate应该先运行,然后根据需要调用其他。。。请给我一个正确的答案Objective c 目标C基本问题,objective-c,uiviewcontroller,uiapplicationdelegate,uiapplication,Objective C,Uiviewcontroller,Uiapplicationdelegate,Uiapplication,我使用基于视图的模板制作了一个简单的应用程序。我只在viewController文件中的view didload方法中放入了nslog,也在applicationDidFinishLaunch方法(在appDelegate中)中放入了nslog,以检查首先调用哪个类文件 运行之后,我得到了:viewController先运行,然后是appdelegate..但我认为appdelegate应该先运行,然后根据需要调用其他。。。请给我一个正确的答案 注意——我没有在appDelegate(在应用程序
注意——我没有在appDelegate(在应用程序didFinishLaunch内部)中调用viewController(没有生成对象)。如果视图控制器是AppDelegate的属性,则我使用的是ios4,类似于代码引用
@interface AppDelegate_Shared : NSObject <UIApplicationDelegate, UIAlertViewDelegate, OMFDataLoadDelegate> {
NSManagedObjectModel *managedObjectModel;
NSManagedObjectContext *managedObjectContext;
NSPersistentStoreCoordinator *persistentStoreCoordinator;
UIWindow *window;
UITabBarController *tabBarController;
}
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;
}
如果初始视图没有加载,那么应用程序显然还没有完成启动
消息按正确的顺序发送。感谢Travish为您提供的支持。我应用了您所建议的,但顺序是1,2,4,3。我的问题是“代码流是什么?”我先阅读了文档“main.m”调用“appdelegate类”,然后调用我们在ApplicationdFinishLaunch方法中编写的其他类。您能解释一下吗。。
- (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;
}