Skip to content

vkrotin/CHSession

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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, vkrotin.ios@gmail.com

License

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

About

This Manager is designed for ease of cache management requests NSURLSession. Valid GET, POST, HEAD requests.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published