Is it possible to inherit from the main class in Objective-C (Xcode / iOS)?

I do not have direct access to the main AppDelegate file (I use the SDL2 application in which the AppDelegate file is compiled)

For testing purposes, is it possible to add a hook to the main application didFinishLaunchingWithOptions or make an inheritance class in Xcode?

+4
source share
1 answer

A solution that may solve your problem is to register for UIApplicationDidFinishLaunchingNotificationin the class loading method. For instance.

+ (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
}
+2
source

Source: https://habr.com/ru/post/1661570/


All Articles