BxUpdateManager
Swift 管理器,用于检查网络和本地的更新。
功能
- 管理加载数据
- 在非并发队列中执行
要求
- iOS 8.0+ : iOS 8.x/9.x/10.x/11.x/12.x/13.x
- Swift 3.0+ : Swift 3.x/4.x/5.x 支持
安装
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。您可以使用以下命令安装它
$ gem install cocoapods
要使用 CocoaPods 将 BxUpdateManager 集成到您的 Xcode 项目中,请将其指定在您的 Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
target '<Your Target Name>' do
pod 'BxUpdateManager', '~> 1.0.0'
end
然后,运行以下命令
$ pod install
Swift 包管理器
Swift 包管理器 是一个用于自动化 Swift 代码发布的工具,它与 swift
编译器集成。它仍处于早期开发阶段,但 BxUpdateManager 支持其在支持平台上的使用。
一旦您设置了 Swift 包,将 BxUpdateManager 添加为依赖项就像将其添加到您的 Package.swift
中的 dependencies
值一样简单。
dependencies: [
.Package(url: "https://github.com/ByteriX/BxUpdateManager.git", majorVersion: 1)
]
手动
如果您不想使用上述任何依赖管理器,您可以将 BxUpdateManager
手动集成到您的项目中。
嵌入式框架
- 打开终端,在顶级项目目录中
cd
,并运行以下命令 "if" 您的项目尚未初始化为 git 仓库
$ git init
- 通过运行以下命令将
BxUpdateManager
添加为 git 子模块
$ git submodule add https://github.com/ByteriX/BxUpdateManager.git
-
将
BxUpdateManager
的所有源文件和资源从本地副本添加到项目的构建阶段。 -
就这样!
使用
示例
class SimpleController: UIViewController, BxUpdateManagerDelegate {
let dataManager = BxUpdateManager(updateDataInterval: 15.0,
updateInterfaceInterval: 5.0,
checkInterval: 1.0,
waitingStrategy: .fromStopLoading,
isActive: false)
override func viewDidLoad() {
super.viewDidLoad()
dataManager.delegate = self
}
func viewWillAppear(_ animated: Bool){
super.viewWillAppear(animated)
// The BxUpdateManager instance initiate as deactivated, then you will need activate it:
dataManager.isActive = true
}
func viewWillDisappear(_ animated: Bool){
super.viewWillDisappear(animated)
// If Controller has deinited then isActive = false should called from destructor and that wouldn't need:
dataManager.isActive = false
}
// MARK - BxUpdateManagerDelegate
func updateManagerLoadData(_ updateManager: BxUpdateManager)
{
// loading...
// When loading is finished without error call that:
updateManager.stopLoading()
//If loading fail with error call that:
// updateManager.stopLoading(error: error)
}
func updateManagerUpdateInterface(_ updateManager: BxUpdateManager)
{
// only for interface updating
}
func updateManagerUpdateData(_ updateManager: BxUpdateManager)
{
// only for data updating
}
}
许可
BxUpdateManager是根据MIT许可证发布的。请参阅LICENSE文件以获取详细信息。