我没有直接访问主AppDelegate文件(我正在使用编译AppDelegate文件的SDL2应用程序)
出于测试目的,是否可以在主应用程序中添加一个钩子didFinishLaunchingWithOptions或在Xcode中创建一个继承类?
最佳答案 可以解决您的问题的解决方案是在类加载方法中注册UIApplicationDidFinishLaunchingNotification.例如.
+ (void)load {
NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver:self
selector:@selector(appDidLaunch)
name:UIApplicationDidFinishLaunchingNotification
object:nil];
}
+ (void)appDidLaunch:(NSNotification *)notification {
NSDictionary *options = [notification userInfo];
// Your code here
}