OpenWeatherSwift 1.0.1

OpenWeatherSwift 1.0.1

测试测试过
语言语言 SwiftSwift
许可证 MIT
发布上次发布2017 年 3 月
SwiftSwift 版本3.0
SPM支持 SPM

Henrik Panhans 维护。



 
依赖关系
Alamofire>= 0
SwiftyJSON>= 0
 

OpenWeatherSwift

这是一个简单的 API,用 Swift 3 编写,基于 OpenWeatherMap.org 的 API

要安装,只需将 pod 'OpenWeatherSwift' 添加到您的 Podfile

使用方法

import OpenWeatherSwift

var newApi = OpenWeatherSwift(apiKey: "_your_api_key_goes_here", temperatureFormat: .Celsius)

以下参数是可用的

  • 语言

    • 英语
    • 俄语
    • 意大利语
    • 西班牙语
    • 乌克兰语
    • 德语
    • 葡萄牙语
    • 罗马尼亚语
    • 波兰语
    • 芬兰语
    • 荷兰语
    • 法语
    • 保加利亚语
    • 瑞典语
    • 繁体中文
    • 简体中文
    • 土耳其语
    • 克罗地亚语
    • 加泰罗尼亚语

  • 温度格式

    • 摄氏度
    • 开尔文
    • 华氏度

以下函数可用: 结果将始终是一个 JSON 对象,可以访问其中值。此外,您还可以创建一个 Weather() 对象,以方便访问 JSON 数据。

newApi.currentWeatherByCoordinates(coords: CLLocationCoordinate2D) { (results) in
       let weather = Weather(data: results)
}


newApi.currentWeatherByCity(name: String) { (result) in
       let weather = Weather(data: results)
}


newApi.currentWeatherByID(id: String) { (result) in
       let weather = Weather(data: results)
}


newApi.currentWeatherByZIP(code: String, countryCode: String) { (result) in
       let weather = Weather(data: results)
}


newApi.forecastWeatherByCoordinates(coords: CLLocationCoordinate2D, type: ForecastType) { (results) in
       let forecast = Forecast(data: results, type: ForecastType)
}


newApi.forecastWeatherByID(id: String, type: ForecastType) { (results) in
       let forecast = Forecast(data: results, type: ForecastType)
}


newApi.forecastWeatherByCity(name: String, type: ForecastType) { (results) in
       let forecast = Forecast(data: results, type: ForecastType)
}

玩得开心,并对使用表示感谢 :)