- iOS 13及以上
导入依赖
import AppBehaviorDispatcher
在AppDelegate中使用
import UIKit
import AppBehaviorDispatcher
class AppDelegate: AppBehaviorDelegate {
var window: UIWindow?
override var behaviors: [ApplicationBehavior] {
return [
RootBehavior()
]
}
}
在某个Behavior文件中使用
import UIKit
import AppBehaviorDispatcher
final class RootBehavior: NSObject, ApplicationBehavior {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Run some code here
return true
}
}
- 在项目导航器中右键点击
- 选择“添加包...”
- 搜索
https://github.com/eugene-software/AppBehaviorDispatcher.git
Eugene Software
AppBehaviorDispatcher可在MIT许可证下使用。有关更多信息,请参阅LICENSE文件。