Latest 0.0.6
Homepage https://github.com/jezzmemo/JJNetwork
License MIT
Platforms ios 8.0, requires ARC
Dependencies AFNetworking
Authors

CocoaPods Compatible
Platform
Build Status
Pod License

AFNetworking-based network library, with delegate to process network response, integrate more business and optimize network performance,Chinese document

Features

  • [x] Sign the http parameter by your customer key
  • [x] Customer cache for the GET and POST
  • [x] Replace the domain to IP address improve performance and change customer http head field

Requirements

  • iOS 8.0 or later
  • Xcode 7.3 or later

Installation

Podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'JJNetwork'
end

run the following command:

$ pod install

Usage

1.Create Request file,extends from APIRequest class,Implement RequestProtocol,For example:

DemoRequest.h

@interface DemoRequest : APIRequest<RequestProtocol>

@end

DemoRequest.m

@implementation DemoRequest

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

@end

2.Create Service extends from APIService,for example:

DemoAPIService.h

@interface DemoAPIService : APIService

- (void)userDetailInfo:(NSInteger)uid;

@end

DemoAPIService.m

@implementation DemoAPIService

- (void)userDetailInfo:(NSInteger)uid{
    //wrapper the parameter
    NSDictionary* parameter = @{@"userid":[NSString stringWithFormat:@"%d",uid]};

    //generate request,set the parameter
    DemoRequest* request = [[DemoRequest alloc] init];
    [request setParameter:parameter];

    //send request
    [self startRequest:request];
}

@end

3.Finaly,Invoke the DemoAPIService,for example:

@interface DemoViewController ()<APIServiceProtocol>

@property(nonatomic,readwrite,strong)DemoAPIService* apiService;

@end

@implementation DemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.apiService userDetailInfo:100];
}

- (DemoAPIService*)apiService{
    if (_apiService != nil) {
    return _apiService;
    }
    _apiService = [[DemoAPIService alloc] init];
    _apiService.serviceProtocol = self;
    return _apiService;
}

#pragma mark - Network response

- (void)responseSuccess:(APIService *)service responseData:(id)data{

}
- (void)responseFail:(APIService *)service errorMessage:(NSError *)error{

}

@end

License

JJNetwork is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "JJNetwork",
    "version": "0.0.6",
    "summary": "JJNetwork.",
    "description": "iOS Network Module",
    "homepage": "https://github.com/jezzmemo/JJNetwork",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Jezz": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/jezzmemo/JJNetwork.git",
        "tag": "0.0.6"
    },
    "public_header_files": "JJNetwork/Source/JJNetwork.h",
    "source_files": "JJNetwork/Source/JJNetwork.h",
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [
            "~> 3.0"
        ]
    },
    "subspecs": [
        {
            "name": "Category",
            "source_files": "JJNetwork/Source/Category/*.{h,m}",
            "public_header_files": "JJNetwork/Source/Category/*.h"
        },
        {
            "name": "Request",
            "source_files": "JJNetwork/Source/Request/*.{h,m}",
            "public_header_files": "JJNetwork/Source/Request/*.h"
        },
        {
            "name": "ThirdParty",
            "source_files": "JJNetwork/Source/ThirdParty/*.{h,m}",
            "public_header_files": "JJNetwork/Source/ThirdParty/*.h",
            "frameworks": "AFNetworking"
        },
        {
            "name": "Cache",
            "dependencies": {
                "JJNetwork/Category": []
            },
            "source_files": "JJNetwork/Source/Cache/*.{h,m}",
            "public_header_files": "JJNetwork/Source/Cache/*.h"
        },
        {
            "name": "APIService",
            "dependencies": {
                "JJNetwork/Category": [],
                "JJNetwork/Request": [],
                "JJNetwork/ThirdParty": [],
                "JJNetwork/Cache": []
            },
            "source_files": "JJNetwork/Source/APIService/*.{h,m}",
            "public_header_files": "JJNetwork/Source/APIService/*.h"
        }
    ]
}

Pin It on Pinterest

Share This