nullproduction / Haneke

A lightweight zero-config image cache for iOS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Haneke

<img src="https://raw.github.com/hpique/Haneke/master/screenshot.png" width="75%" "alt="Screenshot" />

Build Status

A lightweight zero-config image cache for iOS.

Haneke resizes images and caches the result on memory and disk. Everything is done in background, allowing for fast, responsive scrolling. Asking Haneke to load, resize, cache and display an appropiately sized image is as simple as:

[imageView hnk_setImageFromURL:url];

Really.

##Features

  • First-level memory cache using NSCache.
  • Second-level LRU disk cache using the file system.
  • Asynchronous and synchronous image retrieval.
  • Background image resizing and file reading.
  • Thread-safe.
  • Automatic cache eviction on memory warnings or disk capacity reached.
  • Preloading images from the disk cache into memory on startup.
  • Zero-config UIImageView category to use the cache, optimized for UITableView and UICollectionView cell reuse.

##Add Haneke to your project

  1. Add the Haneke folder to your project.
  2. Profit!

##UIImageView category

Haneke provides convenience methods for UIImageView with optimizations for UITableView and UICollectionView cell reuse. Images will be resized appropiately and cached.

// Setting a remote image
[imageView hnk_setImageFromURL:url];

// Setting a local image
[imageView hnk_setImageFromFile:path];

// Setting an image manually. Requires you to provide a key.
[imageView hnk_setImage:image withKey:key];

The above lines take care of:

  1. If cached, retreiving an appropiately sized image (based on the bounds and contentMode of the UIImageView) from the memory or disk cache. Disk access is performed in background.
  2. If not cached, loading the original image from web/disk/memory and producing an appropiately sized image, both in background. Remote images will be retrieved from the shared NSURLCache if available.
  3. Setting the image and animating the change if appropiate.
  4. Or doing nothing if the UIImageView was reused during any of the above steps.
  5. Caching the resulting image.
  6. If needed, evicting the least recently used images in the cache.

##Requirements

Haneke requires iOS 7.0 or above and ARC.

##Roadmap

Haneke is in initial development and its public API should not be considered stable.

##License

Copyright 2014 Hermes Pique (@hpique)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

A lightweight zero-config image cache for iOS.

License:Apache License 2.0


Languages

Language:Objective-C 98.4%Language:C 1.2%Language:Ruby 0.5%