Latest 1.0.4
Homepage https://github.com/greedlab/GreedNetwork
License MIT
Platforms ios 7.0, requires ARC
Dependencies AFNetworking, GreedJSON, GreedEmoji
Frameworks Foundation
Authors

GreedNetwork Join the chat at https://gitter.im/greedlab/GreedNetwork Build Status

a network request util for iOS 7+, based on AFNetworking and GreedJSON

Installation

pod ‘GreedNetwork’

Usage

GRNetworkForm

decalre your network parameters as properties in GRNetworkForm instance’s interface file;

@interface GRTestFrom : GRNetworkForm

@property (nonatomic, strong) NSString *password;

@property (nonatomic, strong) NSString *username;

@property (nonatomic, strong) NSString *q;

@end

you could customize default parameters value in the implementation file;

@implementation GRTestFrom

- (instancetype)init {
    self = [super init];
    if (self) {
        self.username = @"foo";
        self.password = @"foo1";
        self.q = @"test";
    }
    return self;
}

@end

NSObject+GreedNetwork

initialize your GreedNetwork instance and start your network connection with

    - (void)gr_requestWithNetworkForm:(GRNetworkForm *)form
                          success:(void (^)(GRNetworkResponse *responseObject))success
                          failure:(void (^)(GRNetworkResponse *responseObject))failure

that is it!

- (void)testRequest
{
    GRTestForm *form = [[GRTestForm alloc] init];
    form.q = @"GreedNetwork";
    form.password = self.passTextField.text;
    form.username = self.userTextField.text;
    NSLog(@"form:%@",[form gr_dictionary]);
    [self gr_requestWithNetworkForm:form success:^(GRNetworkResponse *responseObject) {
        NSLog(@"request:%@",responseObject.responseDictionary);
    } failure:^(GRNetworkResponse *responseObject) {
        NSLog(@"request:%@",[responseObject.error userInfo]);
    }];
}

GRNetworkQueue

- (void)testQueue
{
    for (NSInteger index = 0; index < 2; index ++) {
        GRTestForm *form = [[GRTestForm alloc] init];
        form.q = @"GreedNetwork";
        form.successBlock = ^(GRNetworkResponse *responseObject) {
            NSLog(@"queue_%@:%@",@(index),responseObject.responseDictionary);
        };
        form.failureBlock = ^(GRNetworkResponse *responseObject) {
            NSLog(@"queue_%@:%@",@(index),[responseObject.error userInfo]);
        };

        NSLog(@"form:%@",[form gr_dictionary]);
        [[GRNetworkQueue getInstance] addForm:form];
    }
}

Advantage

Compared with the other network util based on AFNetworking ,GreedNetwork has these advantages as follows:

1.if you are going to migrate AFNetworking from 2.x to 3.x,we give you GreedNetwork as candidate.

2.when you have decalred the properties in your GRNetworkForm instance, your network request header,request parameters and HTTP body is generated automatically.

3.GreedNetwork is highly customizable to be adopted to your own project;

CHANGELOG

CHANGELOG.md

LICENSE

MIT

Latest podspec

{
    "name": "GreedNetwork",
    "version": "1.0.4",
    "summary": "network request for iOS",
    "description": "network request for iOS, based on AFNetworking and GreedJSON",
    "homepage": "https://github.com/greedlab/GreedNetwork",
    "license": "MIT",
    "authors": {
        "Bell": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/greedlab/GreedNetwork.git",
        "tag": "1.0.4"
    },
    "source_files": [
        "GreedNetwork",
        "GreedNetwork/*.{h,m}"
    ],
    "frameworks": "Foundation",
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [],
        "GreedJSON": [],
        "GreedEmoji": []
    }
}

Pin It on Pinterest

Share This