Latest 0.0.8
Homepage https://github.com/CoderDwang/DWNetworking
License MIT
Platforms ios 8.0
Dependencies AFNetworking, YYCache
Frameworks Foundation, UIKit
Authors

CocoaPods 
CocoaPods 
License
GitHub stars
GitHub forks

logo

  • 基于AFNetworking~>3.2.1 & YYCache~>1.0.4
  • 轻量级 & 可定制
  • Cocoapodspod 'DWNetworking'
  • 最低支持版本iOS 8.0
  • 交流群577506623
  • 自动选择是否使用baseUrl更加方便

QQ群


Applegate.h中进行网络初始化配置,导入头文件DWNetworking

//设置基础url
//(如果有多处不同基础url,
//此段代码也可不加,每次请求即需传入完整url)
[DWNetworking setBaseUrlString:@"设置基础url"];

//设置请求参数与返回参数类型
//(此处为默认数据,可不加此数据)
[DWNetworking setConfigRequestType:DWRequestTypePlainText responseType:DWResponseTypeJSON];

//设置返回缓存数据时是否隐藏error信息/默认不隐藏
[DWNetworking setReturnCacheHiddenError:YES];

//设置是否自动使用缓存
//即为请求失败或者当前无网络连接,
//如果缓存中有数据则返回缓存数据,
//无数据则走失败接口
//(此处为默认数据,可不加此数据)
[DWNetworking setAutoUseCache:YES];

//设置不使用缓存的url
//此url为发送请求时的url
[DWNetworking setNotAutoUseCacheUrls:arr];

//如果想要显示网络状态指示器,则需加入以下代码
导入头文件
#import "AFNetworkActivityIndicatorManager.h"
[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;

//网络状态
[DWNetworking networkEnvironmentChange:^(DWNetworkReachabilityStatus reachabilityStatus) {
    NSLog(@"%ld", reachabilityStatus);
}];

设置自动清除缓存上限,单位为kb

[DWNetworking setAutoCleanCacheSize:1024];

获取当前缓存,此缓存计算方式为使用文件夹计算

[DWNetworking getCachesSize];

清除缓存

[DWNetworking cleanAllCache];

GET请求

[DWNetworking getUrlString:@"请求地址"
 params:@{@"请求参数":@"可为空"} 
 resultCallBack:^(id success, NSError *error) {}];

POST请求

[DWNetworking postUrlString:@"请求地址"
 params:@"请求参数"
  resultCallBack:^(id success, NSError *error) {}];

单图上传

[DWNetworking uploadWithImage:图片对象 
url:@"上传地址" 
fileName:@"文件名,带后缀"
 name:@"与指定的图片相关联的名称,这是由后端写接口的人指定的,如imagefiles" 
 imageType:@"图片类型" parameters:@"请求参数" progress:^(NSProgress *progress) {} 
 resultCallBack:^(id success, NSError *error) {}]

多图上传,参数与单图相似,只不过是以数组存在

[DWNetworking uploadWithImages:<(NSArray<UIImage *> *)> 
url:<(NSString *)>
 fileNames:<(NSArray<NSString *> *)> 
 names:<(NSArray<NSString *> *)> 
 imageType:<(NSString *)> 
 parameters:<(NSDictionary *)> 
 progress:<^(NSProgress *progress)progress> 
 resultCallBack:<^(id success, NSError *error)resultCallBack>];

Latest podspec

{
    "name": "DWNetworking",
    "version": "0.0.8",
    "summary": "u57fau4e8eAFNetworkinguff5e3.2.1 & YYCache~1.0.4",
    "description": "- u57fau4e8e```AFNetworking~>3.2.1``` & ```YYCache~>1.0.4```n- ```u8f7bu91cfu7ea7``` & ```u53efu5b9au5236```n- u6700u4f4eu652fu6301u7248u672c```iOS 8.0```n- u4ea4u6d41u7fa4```577506623```",
    "homepage": "https://github.com/CoderDwang/DWNetworking",
    "license": "MIT",
    "authors": {
        "CoderDwang": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/CoderDwang/DWNetworking.git",
        "tag": "0.0.8"
    },
    "source_files": [
        "DWNetworking",
        "DWNetworking/**/*.{h,m}"
    ],
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "dependencies": {
        "AFNetworking": [
            "~> 3.2.1"
        ],
        "YYCache": [
            "~> 1.0.4"
        ]
    }
}

Pin It on Pinterest

Share This