Skip to content

Latest commit

 

History

History
86 lines (62 loc) · 2.63 KB

File metadata and controls

86 lines (62 loc) · 2.63 KB

THCache

Build Status Pod Version Pod Platform Pod License Coverage Status

These are some helper classes to handle storing and retrieving of standard data structures

Installation

CocoaPods

Install with CocoaPods by adding the following to your Podfile:

platform :ios, '6.1'
pod 'THCache', '~> 0.9.1'

Note: We follow http://semver.org for versioning the public API.

Manually

Or copy the THCache/ directory from this repo into your project.

Usage

With NSString

- (void)StringStorage {
    [THCacher storeItemsToCache:@"ItemToStore" withKey:@"testStringStorageKey"];
    NSString *itemToStore = [THCacher restoreItemsFromCacheWithKey:@"testStringStorageKey"]];
    
    NSError *err;
    [THCacher removeItemsFromCacheWithKey:@"testStringStorageKey"error:&err]
}

With NSArray

- (void)NSArrayStorage {
    NSArray *array = @[@"ItemToStore", @"ItemToStore"];
    [array storeArrayToCacheWithKey:@"testNSArrayStorageKey"];
    array2 = [[NSArray alloc] initArrayFromCacheWithKey:@"testNSArrayStorageKey"];
    
    NSError *err;
    [array removeArrayFromCacheWithKey:@"testNSArrayStorageKey"error:&err];
}

With NSData

- (void)NSDataStorage {
    NSData *data = [@"ItemToStore" dataUsingEncoding:NSUTF8StringEncoding];
    [data storeDataToCacheWithKey:@"testNSDataStorageKey"];
    [data initDataFromCacheWithKey:@"testNSDataStorageKey"];
    
    NSError *err;
    [data removeDataFromCacheWithKey:@"testNSDataStorageKey"error:&err];
}

With NSDictionary

- (void)testNSDictionaryStorage {
    
    NSDictionary *dictionary = @{@"Key1" : @"ItemToStore", @"Key2" : @"ItemToStore"};
    [dictionary storeDictionaryToCacheWithKey:@"testNSDictionaryStorageKey"];
    NSDictionary *dictionary2 = [[NSDictionary alloc] initDictionaryFromCacheWithKey:@"testNSDictionaryStorageKey"];
    
    NSError *err;
    [dictionary removeDictionaryFromCacheWithKey:@"testNSDictionaryStorageKey"error:&err];
}

#Contributions

...are really welcome.

License

Source code of this project is available under the standard MIT license. Please see the license file.