UNICORN - iOS
全メンバ一覧
HNKCache クラス
HNKCache の継承関係図

実体メソッド

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.

引数
entityEntity 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.
formatNameName 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.
errorPtrIf an error occurs, upon return contains an NSError object that describes the problem.
戻り値
An image for the given entity conforming to the given format, or nil if an error ocurred. The image will be returned synchronously but the disk cache will be updated in background.
- (id) initWithName: (NSString*)  name

Initialize a cache with the given name.

引数
nameName 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.

引数
Formatto 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.

引数
entityEntity whose images will be removed.
- (void) removeImagesOfFormatNamed: (NSString*)  formatName

Removes all cached images of the given format.

引数
formatNameName 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.

引数
entityEntity 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.
formatNameName 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.
completionBlockThe 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.
戻り値
YES if image exists in the memory cache (and thus, the completion block was called synchronously), NO otherwise.
- (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.

引数
keyImage cache key.
formatNameName of the format in which the image is desired. The format must have been previously registered with the cache.
completionBlockBlock 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.
戻り値
YES if image exists in the memory cache (and thus, the completion block was called synchronously), NO otherwise.
- (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.

引数
imageImage to add to the cache. Can be nil, in which case the current image associated to the given key and format will be removed.
keyImage cache key.
formatNameName 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.
警告
The image size should match the format. This method won't validate this.
+ (HNKCache *) sharedCache

Returns the shared cache. For simple apps that don't require multiple caches.

プロパティ詳解

- (NSDictionary *) formats
readnonatomicassign

Dictionary of formats registered with the cache.


このクラス詳解は次のファイルから抽出されました: