4
我没有到主AppDelegate中的文件直接访问(我使用SDL2的应用程序,其中的AppDelegate文件编译)是否有可能从Objective-C(Xcode/iOS)中的主类继承?
出于测试目的,是有可能可以将挂钩添加到主应用程序didFinishLaunchingWithOptions或在Xcode中创建一个继承类?
我没有到主AppDelegate中的文件直接访问(我使用SDL2的应用程序,其中的AppDelegate文件编译)是否有可能从Objective-C(Xcode/iOS)中的主类继承?
出于测试目的,是有可能可以将挂钩添加到主应用程序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
}
谢谢。我可以使用这种方法来实现ios推送通知吗?教程建议它必须在AppDelegate文件中实现 – Jibus