Latest 2.1.2
Homepage https://github.com/0x0c/M2DAPIGatekeeper
License MIT
Platforms ios 7.0, requires ARC
Frameworks UIKit, QuartzCore
Authors

[![CI Status](http://img.shields.io/travis/Akira Matsuda/M2DAPIGatekeeper.svg?style=flat)](https://travis-ci.org/Akira Matsuda/M2DAPIGatekeeper)
Version
License
Platform

Requirements

  • Runs on iOS 7.0 or later.

Contribution

Please use git flow and send pull request to develop branch.

Installation

M2DAPIGatekeeper is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "M2DAPIGatekeeper"

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Only two steps to send request like this.

// Send asynchronous request
M2DAPIRequest *r = [M2DAPIRequest GETRequest:[NSURL URLWithString:@"URL"]];
[[r whenSucceeded:^(M2DAPIRequest *request, NSDictionary *httpHeaderFields, id parsedObject) {
    //When result condition is true
}] whenFailed:^(M2DAPIRequest *request, NSDictionary *httpHeaderFields, id parsedObject, NSError *error) {
    //When result condition is false
}];

A lot of methods to control each sequences.
For example,

M2DAPIGatekeeper *gatekeeper = [M2DAPIGatekeeper sharedInstance];
[gatekeeper parseBlock:^id(NSData *data, NSError *__autoreleasing *error) {
    id result = nil;
    if (*error == nil) {
        result = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:error];
    }
    return result;
}];

[gatekeeper resultConditionBlock:^BOOL(M2DAPIRequest *request, NSURLResponse *response, id parsedObject, NSError *__autoreleasing *error) {
    return [(NSHTTPURLResponse *)response statusCode] == 200;
}];

[gatekeeper initializeBlock:^(M2DAPIRequest *request, NSDictionary *params) {
    dispatch_async(dispatch_get_main_queue(), ^{
        // Show hud when start request
    });
}];
[gatekeeper finalizeBlock:^(M2DAPIRequest *request, NSDictionary *httpHeaderField, id parsedObject) {
    dispatch_async(dispatch_get_main_queue(), ^{
        // Dismiss hud when finish request
    });
}];

and so more.

When start connection, unique identifier is generated.
You can use the identifier to cancel request .

NSString *identifier = [gatekeeper sendRequest:...];
[gatekeeper cancelRequestWithIdentifier:identifier];

Please see also M2DAPIGatekeeper.h or M2DAPIRequest.h.

Author

Akira Matsuda, [email protected]

License

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

Latest podspec

{
    "name": "M2DAPIGatekeeper",
    "version": "2.1.2",
    "summary": "Simple API networking framework.",
    "description": "Simple API networking framework.nEasy to send request for Web API.",
    "homepage": "https://github.com/0x0c/M2DAPIGatekeeper",
    "license": "MIT",
    "authors": {
        "Akira Matsuda": "[email protected]"
    },
    "source": {
        "git": "https://github.com/0x0c/M2DAPIGatekeeper.git",
        "tag": "2.1.2"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "Pod/Classes/**/*.{h,m}",
    "public_header_files": [
        "Pod/Classes/M2DAPIGatekeeper/*.h",
        "Pod/Classes/M2DAPIRequest/*.h",
        "Pod/Classes/M2DURLConnectionOperation/*.h",
        "Pod/Classes/NSURLConnectionExtension/*.h",
        "Pod/Classes/NSURLConnectionExtension/**/*.h"
    ],
    "frameworks": [
        "UIKit",
        "QuartzCore"
    ]
}

Pin It on Pinterest

Share This