Latest 2.0.0
Homepage https://github.com/ruibox001/SFHttp
License MIT
Platforms ios 9.0, requires ARC
Frameworks UIKit
Authors

Build Status

一、SFHttp 是基于AFNetworking的封装的网络请求类,主要扩展如下功能:
1、请求采用链试调用
2、网络请求内置YYModel的解析模型
3、自动解析传入的模型并返回
4、网络变化监听


二、请求代码示例
1、get请求调用:

        get
        .url(@"http://www.weather.com.cn/data/sk/101110101.html").addPara(@{@"userId":@"111"})
        .addPara(@{@"userName":@"222"}).resolve(@"weatherinfo",@"MyModel",^(id model){
            if ([model isKindOfClass:[MyModel class]]) {
                NSLog(@"n解析返回:%@",model);
            }
            else if ([model isKindOfClass:[NSArray class]]){
                for (MyModel *p in model) {
                    NSLog(@"n数组解析返回:%@",p);
                }
            }
        }).start();           

2、post请求调用:

        post
        .url(@"http://www.weather.com.cn/data/sk/101110101.html")
        .addPara(@{@"userId":@"111"})
        .addPara(@{@"userName":@"222"})
        .resolve(@"weatherinfo",@"MyModel",^(id model){
            if ([model isKindOfClass:[MyModel class]]) {
                NSLog(@"n解析返回:%@",model);
            }
            else if ([model isKindOfClass:[NSArray class]]){
                for (MyModel *p in model) {
                    NSLog(@"n数组解析返回:%@",p);
                }
            }
        })
        .start();

三、请求返回信息

        请求信息:
        URL: http://www.weather.com.cn/data/sk/101110101.html
        参数: {
            userId = 111;
            userName = 222;
        }
        JSON: {
            "weatherinfo" : {
                "temp" : "20",
                "time" : "17:00",
                "WD" : "西南风",
                "qy" : "970",
                "isRadar" : "1",
                "cityid" : "101110101",
                "city" : "西安",
                "WS" : "1级",
                "WSE" : "1",
                "Radar" : "JC_RADAR_AZ9290_JB",
                "njd" : "暂无实况",
                "SD" : "14%",
                "rain" : "0"
            }
        }

解析返回:

        17:00 - 西南风 - 西安 - 暂无实况 - 20

安装

CocoaPods

       1. 在 Podfile 中添加 pod 'SFHttp'
       2. 执行 pod installpod update

手动安装

    1. 下载`SFHttp`文件夹内的所有内容。
    2. 将`SFHttp`内的源文件添加(拖放)到你的工程。

Latest podspec

{
    "name": "SFHttp",
    "version": "2.0.0",
    "authors": {
        "ruibox001": "[email protected]"
    },
    "homepage": "https://github.com/ruibox001/SFHttp",
    "summary": "SFHttp u662fu57fau4e8eAFNetworkingu7684u5c01u88c5u7684u7f51u7edcu8bf7u6c42u7c7b",
    "source": {
        "git": "https://github.com/ruibox001/SFHttp.git",
        "tag": "v2.0.0"
    },
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "platforms": {
        "ios": "9.0"
    },
    "requires_arc": true,
    "source_files": [
        "SFHttp",
        "SFHttp/**/*.{h,m}"
    ],
    "frameworks": "UIKit",
    "pod_target_xcconfig": {
        "OTHER_SWIFT_FLAGS[config=Release]": "-suppress-warnings"
    }
}

Pin It on Pinterest

Share This