直接创建 HoloBaseLifecycle
的子类,并实现 UIApplicationDelegate
方法即可。
或者创建生命周期分发类,在 load 方法里手动注册该类,以拥有分发生命周期的能力。
HoloLifecycle
将分发主工程的 UIApplicationDelegate
生命周期到这些子类上。
具体的能力参见以上博客及:
To run the example project, clone the repo, and run pod install
from the Example directory first.
@interface HoloLifecycleHomePod : HoloBaseLifecycle
@end
@implementation HoloLifecycleHomePod
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions {
// do something
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// do something
}
@end
or
@interface HoloLifecycleHomePod : NSObject <HoloLifecycleProtocol, UIApplicationDelegate>
@end
@implementation HoloLifecycleHomePod
+ (HoloLifecyclePriority)priority {
return HoloLifecyclePriorityBeforeHigh;
}
+ (void)load {
[[HoloLifecycleManager sharedInstance] registerLifecycle:self];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions {
// do something
return YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// do something
}
@end
HoloLifecycle is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'HoloLifecycle'
gonghonglou, gonghonglou@icloud.com
HoloLifecycle is available under the MIT license. See the LICENSE file for more info.