Latest 1.0.2
Homepage https://github.com/silence0201/SINetworkManager
License MIT
Platforms ios 7.0, requires ARC
Dependencies AFNetworking, YYCache
Authors

A NetworkManager With AFNetworking And YYCache

安装

1. 手动安装

下载项目后,将项目目录下SINetworkManager拖入项目中

2. CocoaPods安装

pod 'SINetworkManager', '~> 1.0'

用法

  1. 导入头文件
    #import "SINetworkManager.h"
  2. 监听网络变化

    [SINetworkManager networkStatusChageWithBlock:^(SINetworkStatusType status) {
            NSLog(@"%ld",status) ;
    }];
  3. 请求数据,默认数据会先解析为JSON,否则解析为String,如果转换失败返回原数据

    [SINetworkManager GET:@"https://www.v2ex.com/api/topics/hot.json" parameters:nil succeess:^(NSURLSessionTask * _Nonnull task, NSDictionary * _Nonnull responseObject) {
    
    } failure:^(NSURLSessionTask * _Nonnull task, NSError * _Nonnull error) {
    
    }] ;
  4. 获取可配置对象,可以动态修改请求过程中的一些参数信息

    [SINetworkManager sharedConfig] ;
  5. 缓存信息回调

    [SINetworkCache cacheForURL:@"http://www.baidu.com" parameters:nil withBlock:^(id responseCache) {
            NSLog(@"%@",responseCache) ;
    }] ;
  6. 如果数据为XML,需要设置解析为XML

    [SINetworkManager setResponseSerializer:SIResponseSerializerXML] ;
    [SINetworkManager GET:@"http://www.w3school.com.cn/example/xmle/note.xml" parameters:nil succeess:^(NSURLSessionTask * _Nonnull task, NSDictionary * _Nonnull responseObject) {
    } failure:^(NSURLSessionTask * _Nonnull task, NSError * _Nonnull error) {
    
    }] ;

SINetworkManager

SINetworkManager is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SINetworkManager",
    "version": "1.0.2",
    "summary": "A NetworkManager With AFNetworking And YYCache.",
    "description": "A Network Manager With AFNetworking And YYCache",
    "homepage": "https://github.com/silence0201/SINetworkManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Silence": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/silence0201/SINetworkManager.git",
        "tag": "1.0.2"
    },
    "source_files": [
        "SINetworkManager",
        "SINetworkManager/**/*.{h,m}"
    ],
    "exclude_files": "SINetworkManager/Exclude",
    "public_header_files": "SINetworkManager/**/*.h",
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [
            "~> 3.1"
        ],
        "YYCache": [
            "~> 1.0"
        ]
    }
}

Pin It on Pinterest

Share This