Latest 1.0.1
Homepage https://github.com/ruibox001/SFRequest
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

Build Status

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

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

get
.url(@"http://www.weather.com.cn/data/sk/101110101.html")
.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"
}
}
2017-09-11 09:10:41.208595+0800 SFRequest[3842:1055264]
解析返回:17:00 – 西南风 – 西安 – 暂无实况 – 20

Latest podspec

{
    "name": "SFRequest",
    "version": "1.0.1",
    "authors": {
        "ruibox001": "[email protected]"
    },
    "homepage": "https://github.com/ruibox001/SFRequest",
    "summary": "SFRequest u662fu57fau4e8eAFNetworkingu7684u5c01u88c5u7684u7f51u7edcu8bf7u6c42u7c7b",
    "source": {
        "git": "https://github.com/ruibox001/SFRequest.git",
        "tag": "v1.0.1"
    },
    "license": "MIT",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": [
        "SFHttp",
        "SFHttp/**/*.{h,m}"
    ],
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This