Latest 1.0.1
Homepage https://github.com/cx478815108/TokenNetworking
License MIT
Platforms ios 8.0, requires ARC
Authors

This tool may be useful!

Code

    TokenNetworking.networking()
    .sendRequest(^NSURLRequest *(TokenNetworking *netobj) {
        return NSMutableURLRequest.token_requestWithURL(@"https://xxxx/xx/xx.html")
                                  .token_setMethod(@"GET")
                                  .token_setUA(UA)
                                  .token_setTimeout(30);
    })
    .transform(^id(TokenNetworking *netWorkingObj, id responsedObj) {
        return [netWorkingObj HTMLTextSerializeWithData:responsedObj];
    })
    .finish(^(TokenNetworking *netWorkingObj,NSURLSessionTask *task, id responsedObj) {
        NSLog(@"html text = %@",responsedObj);
    }, ^(TokenNetworking *netobj,NSError *error) {
        NSLog(@"error,%@",error);
    })
    .afterSendRequest(^NSURLRequest *(TokenNetworking *netobj) {
        NSString *transformURL = @"https://xxx/xx/xxxxx.json";
        return NSMutableURLRequest.token_requestWithURL(transformURL)
                                  .token_setMethod(@"POST");
    })
    .transform(^id(TokenNetworking *netWorkingObj, id responsedObj) {
        return [netWorkingObj JSONSerializeWithData:responsedObj failure:nil];
    })
    .finish(^(TokenNetworking *netWorkingObj,NSURLSessionTask *task, id responsedObj) {
        NSLog(@"%@",responsedObj);

    }, ^(TokenNetworking *netWorkingObj, NSError *error) {
        NSLog(@"error,%@",error);
    });

    //transform block will handle the data in a background thread.
    // see TokenNetworking.h for more details!

Latest podspec

{
    "name": "TokenNetworking",
    "version": "1.0.1",
    "summary": "An easy way to use network and write chainable methods",
    "homepage": "https://github.com/cx478815108/TokenNetworking",
    "license": "MIT",
    "authors": {
        "cx478815108": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/cx478815108/TokenNetworking.git",
        "tag": "v1.0.1"
    },
    "source_files": "TokenNetworking/**/*.{h,m}",
    "requires_arc": true
}

Pin It on Pinterest

Share This