Latest 1.1.0
Homepage https://github.com/LYajun/LGNetworking
License MIT
Platforms ios 8.0, requires ARC
Dependencies AFNetworking
Authors

链式网络管理工具(基于AFNetworking),支持GET、XML解析、POST、TEXT、UPLOAD、DOWNLOAD、PUT、DELETE、PATCH

使用方式

1、安装

pod 'LGNetworking'

2、代码调用

GET:

    NSString *url = @"http://ip:port/xxx?xx=xx";
    NSDictionary *params = @{@"userID":@"10086",
                             @"subjectID":@"S2-English"};
    NSDictionary *httpHeader = @{@"secret":@"9878937873587348578454759435"};
    [LGN.setRequestUrl(url).setRequestType(GET).setParameters(params).setHTTPHeader(httpHeader) startRequestWithSuccess:^(id response) {
        // 请求成功
    } failure:^(NSError *error) {
        // 请求失败
    }];

POST:

    NSString *url = @"http://ip:port/xxx";
    NSDictionary *params = @{@"userID":@"10086",
                             @"subjectID":@"S2-English"};
    NSDictionary *httpHeader = @{@"secret":@"9878937873587348578454759435"};
    [LGN.setRequestUrl(url).setRequestType(POST).setParameters(params).setHTTPHeader(httpHeader) startRequestWithSuccess:^(id response) {
        // 请求成功
    } failure:^(NSError *error) {
        // 请求失败
    }];

TXET(加载本地文本资料):

    NSString *path = @"file://xxx/xxx.txt";
    [LGN.setRequestPath(path).setRequestType(TEXT) startRequestWithSuccess:^(id response) {
        // 请求成功
    } failure:^(NSError *error) {
        // 请求失败
    }];

UPLOAD:

    LGUploadModel *uploadModel = [[LGUploadModel alloc] init];
    UIImage *image = [UIImage imageNamed:@"xx"];
    uploadModel.datas = @[UIImageJPEGRepresentation(image, 0.5)];
    uploadModel.fileNames = @[[NSString stringWithFormat:@"照片%.f.png",[[NSDate date] timeIntervalSince1970]]];
    uploadModel.fileType = @"image/png";
    NSString *url = @"http://ip:port/xxx";
    [LGN.setRequestUrl(url).setRequestType(UPLOAD).setUploadModel(uploadModel) startRequestWithProgress:^(NSProgress *progress) {
        // 上传进度
    } success:^(id response) {
        // 上传成功
    } failure:^(NSError *error) {
        // 上传失败
    }];

DOWNLOAD:

    NSString *url = @"http://ip:port/xxx";
    NSString *savePath = @"file://xxx/xxx.txt";
    [LGN.setRequestUrl(url).setRequestType(DOWNLOAD) startRequestWithProgress:^(NSProgress *progress) {
        // 下载进度
    } success:^(id response) {
        // 下载成功
    } failure:^(NSError *error) {
        // 下载失败
    }];

Latest podspec

{
    "name": "LGNetworking",
    "version": "1.1.0",
    "summary": "u94feu5f0fu7f51u7edcu7ba1u7406u5de5u5177(u57fau4e8eAFNetworking)uff0cu652fu6301GETu3001XMLu3001POSTu3001TEXTu3001UPLOADu3001DOWNLOADu3001PUTu3001DELETEu3001PATCH",
    "homepage": "https://github.com/LYajun/LGNetworking",
    "license": "MIT",
    "authors": {
        "u5218u4e9au519b": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/LYajun/LGNetworking.git",
        "tag": "1.1.0"
    },
    "source_files": "LGNetworking/*.{h,m}",
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": []
    }
}

Pin It on Pinterest

Share This