Courier 0.0.3

Courier 0.0.3

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.


Downloads

Total188,307
Week0
Month0

Installs

Apps15
Test Targets13
powered by Segment

GitHub

Stars4
Watchers2
Forks1
Issues0
Contributors1
Pull Requests0

Code

Files14
LOCLines of Code 674


Courier 0.0.3

Courier is a simple network layer built on NSURLSession and various categories of convenience.

  • Easy network activity display management
  • Respond to changes in reachability
  • Respond to 401 unauthorized errors
  • Request logging
  • Easily build NSURLRequests with proper encoding

Getting Started

#import <Courier/Courier.h>

// Default config
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];

// Add additional headers
config.HTTPAdditionalHeaders = @{@"Accept" : @"application/json"};

// Be a good API citizen and limit to 1 HTTP connection per host
config.HTTPMaximumConnectionsPerHost = 1;

// Build session controller
CRSessionController *sessionController = [CRSessionController sessionControllerWithConfiguration:config 
                                                                                        delegate:controller];

// Build a POST request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithMethod:@"POST"
                                                                 path:@"https://service.com/api"
                                                             encoding:CR_URLJSONParameterEncoding
                                                        URLParameters:@{@"urlParam" : @"value"}
                                                   HTTPBodyParameters:@{@"bodyParam" : @"value"}
                                                               header:@{@"Header-Name" : @"value"}];


// Build a task
NSURLSessionDataTask *task = [sessionController dataTaskForRequest:request
                                                 completionHandler:^(NSData *data,
                                                                     NSURLResponse *response,
                                                                     NSError *error) {
                                                     if (response.success) {
                                                         // Hurrah!
                                                     }
                                                 }];

// Start task
[task resume];

Externals