Latest 0.1.7
Homepage https://github.com/lweisNoN/RMNetWork
License MIT
Platforms ios 8.0, requires ARC
Dependencies AFNetworking
Authors ,

RMNetWork

build
CocoaPods Compatible
Platform

Overview

A Objective-C wrapper around AFNetworking 3.0

Basic usage

1 Installation with CocoaPods

 Source: https://github.com/lweisNoN/RMNetwork.git
 pod 'RMNetwork', '~> 0.1.4'

2 Config baseURL & token if needed

[RMBaseManagerConfig sharedInstance].baseURL = @"";
[RMBaseManagerConfig sharedInstance].baseTokenKeyAndValue = @{@"accessToken":@"foo"};
@required

3 New request

3.1 Subclass of RMBaseRequest

@interface RMNetServiceFoo1API : RMBaseRequest <RMAPIConfig>
@end

3.2 New this subclass request and config request

In implementation of the subclass add config:

Required methods

- (NSString *)requestURL
{
    return @"";
}

- (BOOL) isHTTPS
{
    return YES;
}

- (RMRequestMethod)requestMethod
{
    return RMRequestMethodPost;
}

- (RMRequestSerializerType)requestSerializerType
{
    return RMRequestSerializerTypeJSON;
}

- (RMResponseSerializerType)responseSerializerType
{
    return RMResponseSerializerTypeHTTP;
}

Optional methods

- (NSString *)baseURL
{
    return @"https://www.foo.com";
}

- (NSDictionary *)tokenKeyAndValue

{
    return @{@"accessToken":@"foo"};
}

- (id)parameters
{
    return fooParams;
}

- (RMAFFormDataBlock)rmAFFormDataBlock
{
    return fooBlock;
}

- (NSTimeInterval)timeoutInterval
{
    return fooTimeInterval;
}

3.3 Handle response

Implementation RMRequestDelegate or block to handle reponse

<RMRequestDelegate>
- (void)requestDidSuccess:(RMBaseRequest *)request
{
    NSLog(@"%@",request.responseObject);
}

- (void)requestDidFailure:(RMBaseRequest *)request
{
    NSLog(@"%@",request.error);
}

4 Start net status Monitor

 [[RMNetStatus sharedInstance] startRMNetworkMonitor];

License

MIT

更新说明

0.1.7 修改HTTPMaximumConnectionsPerHost, add author

Latest podspec

{
    "name": "RMNetwork",
    "version": "0.1.7",
    "summary": "For AFNetworking 3.x.",
    "homepage": "https://github.com/lweisNoN/RMNetWork",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "luhai": "[email protected]",
        "Tony Duan": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/lweisNoN/RMNetwork.git",
        "tag": "0.1.7"
    },
    "source_files": "RMNetWork/*.{h,m}",
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [
            "~> 3.0"
        ]
    }
}

Pin It on Pinterest

Share This