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