DTDownloadCache Class Reference
Inherits from | NSObject |
Conforms to | DTDownloadDelegate |
Declared in | DTDownloadCache.h |
Overview
A global cache for DTDownload instances.
Note: all URL parameters may only be remote URLs e.g. http: or https.
Specialized methods for dealing with images. An NSCache holds on to UIImage references after they have been retrieved once since that speeds up subsequent drawing.
Tasks
Accessing the Shared Instance
Downloading Data
-
– cachedDataForURL:option:
-
– cachedDataForURL:option:priority:
-
– cachedDataForURL:option:completion:
-
– cachedDataForURL:option:priority:completion:
Retrieving Information about the Cache
-
– currentDiskUsage
-
maxNumberOfConcurrentDownloads
property -
diskCapacity
property -
loadLastAddedURLFirst
property
Images Methods
Properties
diskCapacity
The maximum disk space used for caching files. The default value is 20 MB.
@property (nonatomic, assign) NSUInteger diskCapacity
Declared In
DTDownloadCache.h
Instance Methods
cachedDataForURL:option:
The URL of the file
- (NSData *)cachedDataForURL:(NSURL *)URL option:(DTDownloadCacheOption)option
Parameters
- URL
The URL of the file
- option
A loading option to specify wheter the file should be loaded if it is already cached.
Return Value
The cached image or nil
if none is cached.
Declared In
DTDownloadCache.h
cachedDataForURL:option:completion:
The URL of the file
- (NSData *)cachedDataForURL:(NSURL *)URL option:(DTDownloadCacheOption)option completion:(DTDownloadCacheDataCompletionBlock)completion
Parameters
- URL
The URL of the file
- option
A loading option to specify wheter the file should be loaded if it is already cached.
- completion
The block to be executed when the file data is available.
Return Value
The cached data or nil
if none is cached.
Declared In
DTDownloadCache.h
cachedDataForURL:option:priority:
The URL of the file
- (NSData *)cachedDataForURL:(NSURL *)URL option:(DTDownloadCacheOption)option priority:(DTDownloadCachePriority)priority
Parameters
- URL
The URL of the file
- option
A loading option to specify wheter the file should be loaded if it is already cached.
- priority
The priority when a download is handled
Return Value
The cached image or nil
if none is cached.
Declared In
DTDownloadCache.h
cachedDataForURL:option:priority:completion:
The URL of the file
- (NSData *)cachedDataForURL:(NSURL *)URL option:(DTDownloadCacheOption)option priority:(DTDownloadCachePriority)priority completion:(DTDownloadCacheDataCompletionBlock)completion
Parameters
- URL
The URL of the file
- option
A loading option to specify wheter the file should be loaded if it is already cached.
- priority
priority
- completion
The block to be executed when the file data is available.
Return Value
The cached data or nil
if none is cached.
Declared In
DTDownloadCache.h
cachedImageForURL:option:
Specialized method for retrieving cached images.
- (UIImage *)cachedImageForURL:(NSURL *)URL option:(DTDownloadCacheOption)option
Parameters
- URL
The URL of the image
- option
A loading option to specify wheter the file should be loaded if it is already cached.
Return Value
The cached image or nil
if none is cached.
Declared In
DTDownloadCache.h
cachedImageForURL:option:completion:
Provides the cached or downloaded image.
- (UIImage *)cachedImageForURL:(NSURL *)URL option:(DTDownloadCacheOption)option completion:(DTDownloadCacheImageCompletionBlock)completion
Parameters
- URL
The URL of the image
- option
A loading option to specify wheter the file should be loaded if it is already cached.
- completion
The block to be executed when the image is available.
Return Value
The cached image or nil
if none is cached.
Discussion
If the image is already cached it will be returned and the block not be executed. If it needs to be loaded then nil
is returned and the block gets executed as soon as the image has been downloaded.
Declared In
DTDownloadCache.h
cachedImageForURL:option:priority:
Specialized method for retrieving cached images.
- (UIImage *)cachedImageForURL:(NSURL *)URL option:(DTDownloadCacheOption)option priority:(DTDownloadCachePriority)priority
Parameters
- URL
The URL of the image
- option
A loading option to specify wheter the file should be loaded if it is already cached.
- priority
The priority when a download is handled
Return Value
The cached image or nil
if none is cached.
Declared In
DTDownloadCache.h
cachedImageForURL:option:priority:completion:
Provides the cached or downloaded image.
- (UIImage *)cachedImageForURL:(NSURL *)URL option:(DTDownloadCacheOption)option priority:(DTDownloadCachePriority)priority completion:(DTDownloadCacheImageCompletionBlock)completion
Parameters
- URL
The URL of the image
- option
A loading option to specify wheter the file should be loaded if it is already cached.
- priority
The priority when a download is handled
- completion
The block to be executed when the image is available.
Return Value
The cached image or nil
if none is cached.
Discussion
If the image is already cached it will be returned and the block not be executed. If it needs to be loaded then nil
is returned and the block gets executed as soon as the image has been downloaded.
Declared In
DTDownloadCache.h