Latest 0.2
Homepage https://github.com/dkhamsing/DKDataCache
License MIT
Platforms ios 7.0, requires ARC
Authors

Simple iOS Data Cache

Build Status
Version
License
Platform

DKDataCache can be used to cache images retrieved from an URL

Installation

CocoaPods

pod 'DKDataCache'

Manual

Add the files in the DKDataCache folder to your project.

Usage

NSString *key = @"http://lorempixel.com/100/100/cats/2/";

// get cache
NSData *data = [[DKDataCache sharedInstance] dataForKey:key];

if (data) {
  UIImage *image = [UIImage imageWithData:data];
  // yay
  return;
}

NSURL *url = [NSURL URLWithString:key];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
  if (data) {
    // set cache
    [[DKDataCache sharedInstance] cacheData:data forKey:key];
    UIImage *image = [UIImage imageWithData:data];
    // nice
  }
}];

Demo

DKDataCache includes a sample project in the Demo folder.

Contact

License

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

Latest podspec

{
    "name": "DKDataCache",
    "version": "0.2",
    "summary": "Simple iOS Data Cache.",
    "homepage": "https://github.com/dkhamsing/DKDataCache",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "dkhamsing": "[email protected]"
    },
    "social_media_url": "http://twitter.com/dkhamsing",
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/dkhamsing/DKDataCache.git",
        "tag": "0.2"
    },
    "source_files": "DKDataCache/*",
    "requires_arc": true
}

Pin It on Pinterest

Share This