AFWeather 1.0.1

AFWeather 1.0.1

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2015年3月

Alvaro Franco 维护。




AFWeather 1.0.1

alt text

获取天气预报从未如此简单,它支持 5 个不同的服务。它返回原始 json,因此您可以轻松获取所需的数据。

alt text

安装

AFWeather 可在 CocoaPods 上获得,您可以通过将以下行添加到您的 Podfile 来获得它

pod 'AFWeather', '~> 1.0'

如果您不使用 CocoaPods,您将不得不将这些文件导入到您的项目中

AFWeather.h
AFWeather.m

支持的服务

服务名称 地点名称/邮编码 坐标 AFWeather 名称
World Weather Online :white_check_mark: :white_check_mark: AFWeatherAPIWorldWeatherOnline
Weather Underground :white_check_mark: :no_entry_sign: AFWeatherAPIWeatherUnderground
Open Weather Map :white_check_mark: :white_check_mark: AFWeatherAPIOpenWeatherMap
AccuWeather :white_check_mark: :no_entry_sign: AFWeatherAPIAccuWeather
Forecast.io :no_entry_sign: :white_check_mark: AFWeatherAPIForecast

使用方法

首先,请确保您已将主类导入到将要播放音频的类中。

#import "AFWeather.h"

配置客户端

为了让 AFWeather 知道您使用的是哪个服务以及您的 API 密钥,请使用方法 -configureClientWithService:withAPIKey:。示例

[[AFWeather sharedClient]configureClientWithService:AFWeatherAPIForecast withAPIKey:@"myawesomeapikey"];

通过城市名称或邮编获取预报

为此,请使用 -fetchForecastOfLocationWithName:andCompletionBlock:

示例

    [[AFWeather sharedClient]fetchForecastOfLocationWithName:@"Murcia" andCompletionBlock:^(NSDictionary *response, NSError *error) {

        if (!error) {

            // Handle the response dictionary with all the information

        } else {

            //Handle the error
        }
    }];

通过坐标获取预报

您还可以使用纬度和经度代替地点名称。

    [[AFWeather sharedClient]fetchForecastOfLocationWithLatitude:@"121.518446" andLogitude:@"-26.181156" andCompletionBlock:^(NSDictionary *response, NSError *error) {

        if (!error) {

            // Handle the response dictionary with all the information

        } else {

            //Handle the error
        }
    }];

许可证

AFWeather 使用 MIT 许可证,因此请随意使用它!

作者

由 Alvaro Franco 制作。如果您有任何问题,请随时给我留言[email protected]