Giter Club home page Giter Club logo

rtnetworking's Introduction

CTNetworking

CTNetworking is an iOS discrete HTTP API calling framework based on AFNetworking.Click for more detail(in Chinese)

Requirements

CTNetworking works on iOS 8.0+ and requires ARC to build. It depends on the following Apple frameworks, which should already be included with most Xcode templates:

  • Foundation.framework
  • UIKit.framework
  • CoreGraphics.framework
  • QuartzCore.framework
  • AFNetworking

You will need the latest developer tools in order to build CTNetworking. Old Xcode versions might work, but compatibility will not be explicitly maintained.

Adding CTNetworking to your project

Demo

Just download or clone the whole project and DO NOT FORGET $ pod update --verbose

Usage

Call API

CTNetworking API URL is constituted by 4 part:

CTService+CTService Version+API method Name+API Parameters

Custom a CTService

Inherit CTService and follow CTServiceProtocal

@interface GDMapService : CTService <CTServiceProtocal>

Implement all methods of CTServiceProtocal

...
- (NSString *)onlineApiBaseUrl
{
    return @"http://restapi.amap.com";
}
- (NSString *)onlineApiVersion
{
    return @"v3";
}
...

Custom an APIManager

Inherit CTAPIBaseManager and follow CTAPIManager Protocal

@interface TestAPIManager : CTAPIBaseManager <CTAPIManager>

Implement all methods of CTAPIManager

...
- (NSString *)methodName
{
    return @"geocode/regeo";
}

- (NSString *)serviceType
{
    return kCTServiceGDMapV3;
}

- (CTAPIManagerRequestType)requestType
{
    return CTAPIManagerRequestTypeGet;
}
...

Call API

Instantiation of API Manager in class

@property (nonatomic, strong) TestAPIManager *testAPIManager;

- (TestAPIManager *)testAPIManager
{
    if (_testAPIManager == nil) {
        _testAPIManager = [[TestAPIManager alloc] init];
        _testAPIManager.delegate = self;
        _testAPIManager.paramSource = self;
    }
    return _testAPIManager;
}

Implement methods of CTAPIManagerParamSource and CTAPIManagerCallBackDelegate

#pragma mark - CTAPIManagerParamSource
- (NSDictionary *)paramsForApi:(CTAPIBaseManager *)manager
{
    return parmas;
}

#pragma mark - CTAPIManagerCallBackDelegate
- (void)managerCallAPIDidSuccess:(CTAPIBaseManager *)manager
{
    //do something
}
- (void)managerCallAPIDidFailed:(CTAPIBaseManager *)manager
{
    //do something
}

And easy to use

[self.testAPIManager loadData];

AppContext settings

You SHOULD custom CTAppContext to set App networking layer settings. Also, you can add more settings to use.

See more in demo and Click for more detail(in Chinese)

Enjoy.

License

This code is distributed under the terms and conditions of the MIT license.

rtnetworking's People

Contributors

casatwy avatar cctv1237 avatar chinsyo avatar czwen avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.