TBAKit
安装
TBAKit 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod "TBAKit"
要获取 The Blue Alliance API 的 API 密钥,您可以在 The Blue Alliance 的 账户面板 上生成一个
示例
要运行示例项目,请克隆仓库,然后从 Example 目录运行 pod install
设置 TBAKit 实例(或使用单例)进行 API 调用
func fetchStatusSingleton() {
TBAKit.sharedKit.apiKey = "abc123"
let task = TBAKit.sharedKit.fetchStatus { (status, error) in
if let error = error {
print(error)
return
}
print(status)
}
}
func fetchStatusInstance() {
let kit = TBAKit(apiKey: "abc123")
let task = kit.fetchStatus { (status, error) in
if let error = error {
print(error)
return
}
print(status)
}
}
添加测试
如果您想修改或添加测试,请在 data
目录中找到本地的测试文件。本地的测试文件是从 API 端点发送到模拟请求的静态 JSON 响应。要命名文件,请将 API 端点名称中的斜杠替换为下划线,并确保文件以 .json
扩展名保存
URL => https://www.thebluealliance.com/api/v3/team/frc2337/event/2016micmp/status
Filename => team_frc2337_event_2016micmp_status
许可证
TBAKit 在 MIT 许可证下可用。有关更多信息,请参见 LICENSE 文件。