UNICORN - iOS
|
実体メソッド | |
Getting images | |
(UIImage *) | - imageForEntity:formatName:error: |
(BOOL) | - retrieveImageForEntity:formatName:completionBlock: |
(BOOL) | - retrieveImageForKey:formatName:completionBlock: |
Setting images | |
(void) | - setImage:forKey:formatName: |
Removing images | |
(void) | - removeAllImages |
(void) | - removeImagesOfFormatNamed: |
(void) | - removeImagesOfEntity: |
Initializing the cache | |
NSDictionary * | formats |
(id) | - initWithName: |
(void) | - registerFormat: |
(HNKCache *) | + sharedCache |
- (UIImage *) imageForEntity: | (id<HNKCacheEntity>) | entity | |
formatName: | (NSString *) | formatName | |
error: | (NSError*__autoreleasing *) | errorPtr | |
Synchronously retrieves the image for the given entity conforming to the given format from memory or disk cache, or creates it if it doesn't exist.
entity | Entity that represents the original image. If an image for the given entity and format doesn't exist in the cache, the entity will be asked to provide the original data or image to create it. |
formatName | Name of the format in which the image is desired. The format must have been previously registered with the cache. If an image for the given key and format doesn't exist in the cache, it will be created based on the format. If by creating the image the format disk capacity is surpassed, least recently used images of the format will be removed until it isn't. |
errorPtr | If an error occurs, upon return contains an NSError object that describes the problem. |
- (id) initWithName: | (NSString*) | name |
Initialize a cache with the given name.
name | Name of the cache. Used as the name of the subdirectory for the disk cache. |
- (void) registerFormat: | (HNKCacheFormat*) | format |
Registers a format in the cache. Haneke will automatically update the diskSize of the format as images are added. If a format with the same name already exists in the cache, it will be cleared first.
Format | to be registered in the cache. If the format preload policy allows it, Haneke will add some or all images cached on disk to the memory cache. If an image of the given format is requested, Haneke will cancel preloading to give priority to the request. A format can only be registered in one cache. |
- (void) removeAllImages |
Removes all cached images.
- (void) removeImagesOfEntity: | (id<HNKCacheEntity>) | entity |
Removes all cached images of the given entity.
entity | Entity whose images will be removed. |
- (void) removeImagesOfFormatNamed: | (NSString*) | formatName |
Removes all cached images of the given format.
formatName | Name of the format whose images will be removed. |
- (BOOL) retrieveImageForEntity: | (id<HNKCacheEntity>) | entity | |
formatName: | (NSString *) | formatName | |
completionBlock: | (void(^)(UIImage *image, NSError *error)) | completionBlock | |
Retrieves an image from the cache, or creates one if it doesn't exist. If the image exists in the memory cache, the completion block will be executed synchronously. If the image has to be retreived from the disk cache or has to be created, the completion block will be executed asynchronously.
entity | Entity that represents the original image. If the image doesn't exist in the cache, the entity will be asked to provide the original data or image to create it. Any calls to the entity will be done in the main queue. |
formatName | Name of the format in which the image is desired. The format must have been previously registered with the cache. If the image doesn't exist in the cache, it will be created based on the format. If by creating the image the format disk capacity is surpassed, least recently used images of the format will be removed until it isn't. |
completionBlock | The block to be called with the requested image. Always called from the main queue. Will be called synchronously if the image exists in the memory cache, or asynchronously if the image has to be retreived from the disk cache or has to be created. |
- (BOOL) retrieveImageForKey: | (NSString*) | key | |
formatName: | (NSString *) | formatName | |
completionBlock: | (void(^)(UIImage *image, NSError *error)) | completionBlock | |
Retrieves an image from the cache. If the image exists in the memory cache, the completion block will be executed synchronously. If the image has to be retreived from the disk cache, the completion block will be executed asynchronously.
key | Image cache key. |
formatName | Name of the format in which the image is desired. The format must have been previously registered with the cache. |
completionBlock | Block to be called with the requested image. Always called from the main queue. Will be called synchronously if the image exists in the memory cache, or asynchronously if the image exists in the disk cache. |
- (void) setImage: | (UIImage*) | image | |
forKey: | (NSString*) | key | |
formatName: | (NSString*) | formatName | |
Sets the image of the given key for the given format. The image is added to the memory cache and the disk cache if the format allows it.
image | Image to add to the cache. Can be nil, in which case the current image associated to the given key and format will be removed. |
key | Image cache key. |
formatName | Name of the format of the given image. You can use this method to pre-populate the cache, invalidate a specific image or to add resized images obtained elsewhere (e.g., a web service that generates thumbnails). In other cases, it's best to let the cache create the resized images. |
+ (HNKCache *) sharedCache |
Returns the shared cache. For simple apps that don't require multiple caches.
|
readnonatomicassign |
Dictionary of formats registered with the cache.