我没有直接访问主 AppDelegate 文件的权限(我正在使用编译 AppDelegate 文件的 SDL2 应用程序)
出于测试目的,是否可以向主应用程序 didFinishLaunchingWithOptions 添加一个 Hook 或在 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
}
关于ios - 是否可以从 Objective-C (Xcode/iOS) 中的主类继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40740456/