Skip to content

Latest commit

 

History

History
80 lines (60 loc) · 2.48 KB

README.md

File metadata and controls

80 lines (60 loc) · 2.48 KB

CHSession

Version License Platform

This Manager is designed for ease of cache management requests NSURLSession. Valid GET, POST, HEAD requests. It is possible to set the size of the allocated memory for the cache. It is also possible to set the size of the allocated space for the cache on disk. Cache management: *entry *reading *cleaning

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

#import "CHSessionManager.h"
// install Cash size
// AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [CHSessionManager setDefaultCapacity];
    ...
 
// Request in some class

// GET
[CHSessionManager getUrl:someURL
                  parameters:dict params, maybe nil
             timeoutInterval:HTTP_DEFAULT_TIMEOUT
                  cachPolicy:CHRequestReturnCacheDataElseLoad
           completionHandler:^(NSData *data, NSURLResponse *response){
               // do something with data or responce out code
           }errorHandler:^(NSError *error){
               // cath the error
           }];

// POST, while no cache
[CHSessionManager postUrl:someURL
                   parameters:dict params, maybe nil
              timeoutInterval:HTTP_DEFAULT_TIMEOUT
            completionHandler:^(NSData *data, NSURLResponse *response){
                // do something with data or responce out code
            } errorHandler:^(NSError *error){
               // cath the error
            }];

// HEAD
[CHSessionManager headUrl:someURL
                   parameters:nil
              timeoutInterval:HTTP_DEFAULT_TIMEOUT
            completionHandler:^(NSDictionary *headDictionary, NSURLResponse *responce){
                // do something with HEAD dictionary or responce out code
            }errorHandler:nil];
           
           

Installation

CHSession is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "CHSession"

Author

Aleksey Anisimov, [email protected]

License

CHSession is available under the MIT license. See the LICENSE file for more info.