TMCache – the best iOS caching library

TMCache - iOS caching library

When it comes to having a cached content in the app I use a 3rd party library named TMCache for the last few years, and I can say that I am really satisfied with it. You can find more info about this awesome caching library here. It is a key/value store designed for persisting temporary objects that are expensive to reproduce, such as downloaded data or the results of slow processing.

I will show you how easy it is to save and load objects with it:

Save object:

UIImage *img = [UIImage imageNamed:@"someImage.jpg"];
[[TMCache sharedCache] setObject:img forKey:@"image" block:nil];

Load object:

[[TMCache sharedCache] objectForKey:@"image"
                              block:^(TMCache *cache, NSString *key, id object) {
                                  UIImage *image = (UIImage *)object;
                                  NSLog(@"image scale: %f", image.scale);
                              }];
Recommended for you: I ❤ Swift [Part 2] – Multiple UITableViewCells in UITableView

Leave a Reply

Your email address will not be published. Required fields are marked *