Inherits from NSObject
Conforms to RMTileCache
Declared in RMTileCache.h

Overview

An RMTileCache object manages memory-based and disk-based caches for map tiles that have been retrieved from the network.

An RMMapView has one RMTileCache across all tile sources, which is further divided according to each tile source’s uniqueTilecacheKey property in order to keep tiles separate in the cache.

An RMTileCache is a key component of offline map use. All tile requests pass through the tile cache and are served from cache if available, avoiding network operation. If tiles exist in cache already, a tile source that is instantiated when offline will still be able to serve tile imagery to the map renderer for areas that have been previously cached. This can occur either from normal map use, since all tiles are cached after being retrieved, or from proactive caching ahead of time using the beginBackgroundCacheForTileSource:southWest:northEast:minZoom:maxZoom: method.

Properties

backgroundCacheDelegate

A delegate to notify of background tile cache download operations.

@property (nonatomic, weak) id<RMTileCacheBackgroundDelegate> backgroundCacheDelegate

Discussion

A delegate to notify of background tile cache download operations.

Declared In

RMTileCache.h

isBackgroundCaching

Whether or not the tile cache is currently background caching.

@property (nonatomic, readonly, assign) BOOL isBackgroundCaching

Discussion

Whether or not the tile cache is currently background caching.

Declared In

RMTileCache.h

tileCaches

The list of caches managed by a cache manager. This could include memory-based, disk-based, or other types of caches.

@property (nonatomic, readonly, strong) NSArray *tileCaches

Discussion

The list of caches managed by a cache manager. This could include memory-based, disk-based, or other types of caches.

Declared In

RMTileCache.h

Class Methods

tileHash:

Return an identifying hash number for the specified tile.

+ (NSNumber *)tileHash:(RMTile)tile

Parameters

tile

A tile image to hash.

Return Value

A unique number for the specified tile.

Discussion

Return an identifying hash number for the specified tile.

Declared In

RMTileCache.h

Instance Methods

addCache:

Adds a given cache to the cache management system.

- (void)addCache:(id<RMTileCache>)cache

Parameters

cache

A memory-based or disk-based cache.

Discussion

Adds a given cache to the cache management system.

Declared In

RMTileCache.h

beginBackgroundCacheForTileSource:southWest:northEast:minZoom:maxZoom:

Tells the tile cache to begin background caching. Progress during the caching operation can be observed by implementing the RMTileCacheBackgroundDelegate protocol.

- (void)beginBackgroundCacheForTileSource:(id<RMTileSource>)tileSource southWest:(CLLocationCoordinate2D)southWest northEast:(CLLocationCoordinate2D)northEast minZoom:(NSUInteger)minZoom maxZoom:(NSUInteger)maxZoom

Parameters

tileSource

The tile source from which to retrieve tiles.

southWest

The southwest corner of the geographic area to cache.

northEast

The northeast corner of the geographic area to cache.

minZoom

The minimum zoom level to cache.

maxZoom

The maximum zoom level to cache.

Discussion

Tells the tile cache to begin background caching. Progress during the caching operation can be observed by implementing the RMTileCacheBackgroundDelegate protocol.

Declared In

RMTileCache.h

cancelBackgroundCache

Cancel any background caching.

- (void)cancelBackgroundCache

Discussion

Cancel any background caching.

This method returns immediately so as to not block the calling thread. If you wish to be notified of the actual cancellation completion, implement the tileCacheDidCancelBackgroundCache: delegate method.

Declared In

RMTileCache.h

initWithExpiryPeriod:

Initializes and returns a newly allocated cache object with specified expiry period.

- (id)initWithExpiryPeriod:(NSTimeInterval)period

Parameters

period

A period of time after which tiles should be expunged from the cache.

Return Value

An initialized cache object or nil if the object couldn’t be created.

Discussion

Initializes and returns a newly allocated cache object with specified expiry period.

If the init method is used to initialize a cache instead, a period of 0 is used. In that case, time-based expiration of tiles is not performed, but rather the cached tile count is used instead.

Declared In

RMTileCache.h

tileCountForSouthWest:northEast:minZoom:maxZoom:

A count of the number of tiles that would be downloaded in a background tile cache download operation.

- (NSUInteger)tileCountForSouthWest:(CLLocationCoordinate2D)southWest northEast:(CLLocationCoordinate2D)northEast minZoom:(NSUInteger)minZoom maxZoom:(NSUInteger)maxZoom

Parameters

southWest

The southwest corner of the geographic area to cache.

northEast

The northeast corner of the geographic area to cache.

minZoom

The minimum zoom level to cache.

maxZoom

The maximum zoom level to cache.

Return Value

The number of tiles representing the coverage area.

Discussion

A count of the number of tiles that would be downloaded in a background tile cache download operation.

Declared In

RMTileCache.h