Possible to change AppDelegate at runtime

2019-05-22 13:48发布

问题:

Is it possible to change the UIApplication.delegate property at runtime to another class that implements the UIApplicationDelegate protocol so that from then on UIApplicationDelegate functions are called on the new class?

回答1:

You can very simply change it with [UIApplication sharedApplication].delegate = instanceOfDifferentClass.