测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2017 年 10 月 |
SwiftSwift 版本 | 4.0 |
SPM支持 SPM | ✗ |
由 Thorsten Stark,Cornelius Horstmann,Pascal Stüdlein 维护。
RemoteSettings 是一个框架,帮助您获取远程数据并将其存储到特定的数据结构中。
实验性:我们还提供了 Playground 作为文档,请查看:)。并确保“显示渲染的 Markdown”已激活。
让我们假设我们想使用 GitHub API 来获取关于 RemoteSettings 项目的信息。更具体地说,我们想存储 RemoteSettings 仓库的 url 以备后用。
let apiUrl = URL(string:"https://api.github.com/repos/tbointeractive/remotesettings")!
open func update(_ data: Data) throws
并处理获取的数据SubclassOfRemoteSettings(remote: apiUrl)
public func update(finished: Completion?)
使用该对象来获取数据伪代码
final class GitHubRemoteSettings: RemoteSettings {
var repoUrl: URL?
open override func update(_ data: Data) throws {
self.repoUrl = // parse data (in this case this is some json), extract the repoUrl and store in member variable
}
}
let remoteSettings = GitHubRemoteSettings(remote: apiUrl)
remoteSettings.update() { error in
// error handling
}
// after an update your designated data is stored to repoUrl
remoteSettings.repoUrl
当您需要处理类似我们之前部分中需要处理的 JSON 数据时,JSONRemoteSettings 非常方便。
open func update(_ data: [AnyHashable: Any]) throws
和 open func update(_ data: [Any]) throws
update(_ data: [AnyHashable: Any])
,要么调用 update(_ data: [Any])
。SubclassOfJSONRemoteSettings(remote: apiUrl)
public func update(finished: Completion?)
使用该对象来获取数据TBD
TBD
TBD