Skip to content

Latest commit

 

History

History
62 lines (43 loc) · 1.46 KB

README.md

File metadata and controls

62 lines (43 loc) · 1.46 KB

LYWebService

an weak coupling and convenient network request util based on AFNetworking. could support auto Params and Data Parser,auto create reuqest. also support flexible custom Parser settings...

Requirements

AFNetworking

Installation with Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

Then update dependents :

$ sh update.sh

Usage

configure LYWebClient

LYWebClientInstance.endPoint = [NSURL URLWithString:@"http://route.showapi.com"];
[LYWebClientInstance setPublicParams:[[LYPublicParamsDefault alloc] init]];
...    

Creating API

@protocol LYTextApi <LYWebService>

@GET("/967-1")
- (NSURLSessionDataTask*)getInfo:(NSString *)showapi_appid
                    suceessBlock:LY_SUCCESS_BLOCK(NSArray<LYTextModel *> *)callback
failBlock:LY_FAIL_BLOCK(NSString*)errorMessage;

@end

do task

[LYWebRequest(LYTextApi) getInfo:@"my_appSecret" suceessBlock:^(NSArray *result, NSURLResponse *response) {
        NSLog(@"LYWebRequest Suceess");
    } failBlock:^(NSString *errorMessage, NSURLResponse *response, NSError *error) {
        NSLog(@"LYWebRequest fail");
    }];

@end