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.

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

loadLastAddedURLFirst

Settings which URLs should be loaded first

@property (nonatomic, assign) BOOL loadLastAddedURLFirst

Discussion

NO -> load first added URLs first YES -> load last added URLs first

Declared In

DTDownloadCache.h

maxNumberOfConcurrentDownloads

The number of downloads that can go on at the same time.

@property (nonatomic, assign) NSUInteger maxNumberOfConcurrentDownloads

Declared In

DTDownloadCache.h

Class Methods

sharedInstance

Access the shared cache.

+ (DTDownloadCache *)sharedInstance

Return Value

the shared instance of the download cache.

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

currentDiskUsage

current sum of cached files in Bytes

- (NSUInteger)currentDiskUsage

Declared In

DTDownloadCache.h