MLNOfflineStorage class
MLNOfflineStorage implements a singleton (shared object) that manages offline
packs and ambient caching. All of this class’s instance methods are asynchronous,
reflecting the fact that offline resources are stored in a database. The shared
object maintains a canonical collection of offline packs in its packs property.
Mapbox resources downloaded via this API are subject to separate Vector Tile and Raster Tile API pricing and are not included in the Maps SDK’s “unlimited” requests. See our pricing page for more information.
Related examples
Constructors
- MLNOfflineStorage()
-
Returns a new instance of MLNOfflineStorage constructed with the default
newmethod.factory - MLNOfflineStorage.castFrom(ObjCObjectBase other)
-
Constructs a MLNOfflineStorage that points to the same underlying object as
other. -
MLNOfflineStorage.castFromPointer(Pointer<
ObjCObject> other, {bool retain = false, bool release = false}) - Constructs a MLNOfflineStorage that wraps the given raw object pointer.
Properties
- countOfBytesCompleted → int
-
The cumulative size, measured in bytes, of all downloaded resources on disk.
no setter
- databasePath → NSString
-
The file path at which offline packs and the ambient cache are stored.
no setter
- databaseURL → NSURL
-
The file URL at which offline packs and the ambient cache are stored.
no setter
- debugDescription$1 → NSString
-
debugDescription
no setterinherited
- delegate ↔ MLNOfflineStorageDelegate?
-
The receiver’s delegate.
getter/setter pair
- description$1 → NSString
-
description
no setterinherited
- hash$1 → int
-
hash
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isProxy → bool
-
isProxy
no setterinherited
- packs → NSArray?
-
An array of all known offline packs, in the order in which they were created.
no setter
- ref → ObjCObjectRef
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- superclass$1 → ObjCObjectBase
-
superclass
no setterinherited
Methods
-
addContentsOfFile(
NSString filePath, {ObjCBlock< Void Function(NSURL, NSArray?, NSError?)> ? withCompletionHandler}) → void - Adds the offline packs located at the given file path to offline storage.
-
addContentsOfURL(
NSURL fileURL, {ObjCBlock< Void Function(NSURL, NSArray?, NSError?)> ? withCompletionHandler}) → void - Adds the offline packs located at the given URL to offline storage.
-
addPackForRegion(
MLNOfflineRegion region, {required NSData withContext, ObjCBlock< Void Function(MLNOfflinePack?, NSError?)> ? completionHandler}) → void - Creates and registers an offline pack that downloads the resources needed to use the given region offline.
-
autorelease(
) → MLNOfflineStorage - autorelease
-
class$1(
) → ObjCObjectBase -
class
inherited
-
clearAmbientCacheWithCompletionHandler(
ObjCBlock< Void Function(NSError?)> completion) → void - Clears the ambient cache by deleting resources. This method does not affect resources shared with offline regions.
-
conformsToProtocol$1(
Protocol aProtocol) → bool -
conformsToProtocol:
inherited
-
copy(
) → ObjCObjectBase -
copy
inherited
-
dealloc(
) → void -
dealloc
inherited
-
doesNotRecognizeSelector(
Pointer< ObjCSelector> aSelector) → void -
doesNotRecognizeSelector:
inherited
-
forwardingTargetForSelector(
Pointer< ObjCSelector> aSelector) → ObjCObjectBase -
forwardingTargetForSelector:
inherited
-
forwardInvocation(
NSInvocation anInvocation) → void -
forwardInvocation:
inherited
-
init(
) → MLNOfflineStorage - init
-
invalidateAmbientCacheWithCompletionHandler(
ObjCBlock< Void Function(NSError?)> completion) → void - Invalidates the ambient cache. This method checks that the tiles in the ambient cache match those from the server. If the local tiles do not match those on the server, they are re-downloaded.
-
invalidatePack(
MLNOfflinePack pack, {required ObjCBlock< Void Function(NSError?)> withCompletionHandler}) → void - Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated.
-
isEqual(
ObjCObjectBase object) → bool -
isEqual:
inherited
-
isKindOfClass(
ObjCObjectBase aClass) → bool -
isKindOfClass:
inherited
-
isMemberOfClass(
ObjCObjectBase aClass) → bool -
isMemberOfClass:
inherited
-
methodForSelector(
Pointer< ObjCSelector> aSelector) → Pointer<NativeFunction< Void Function()> > -
methodForSelector:
inherited
-
methodSignatureForSelector(
Pointer< ObjCSelector> aSelector) → NSMethodSignature -
methodSignatureForSelector:
inherited
-
mutableCopy(
) → ObjCObjectBase -
mutableCopy
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
performSelector(
Pointer< ObjCSelector> aSelector) → ObjCObjectBase -
performSelector:
inherited
-
performSelector$1(
Pointer< ObjCSelector> aSelector, {required ObjCObjectBase withObject}) → ObjCObjectBase -
performSelector:withObject:
inherited
-
performSelector$2(
Pointer< ObjCSelector> aSelector, {required ObjCObjectBase withObject, required ObjCObjectBase withObject$1}) → ObjCObjectBase -
performSelector:withObject:withObject:
inherited
-
preloadData(
NSData data, {required NSURL forURL, NSDate? modificationDate, NSDate? expirationDate, NSString? eTag, required bool mustRevalidate}) → void - Inserts the provided resource into the ambient cache.
-
preloadData$1(
NSData data, {required NSURL forURL, NSDate? modificationDate, NSDate? expirationDate, NSString? eTag, required bool mustRevalidate, ObjCBlock< Void Function(NSURL, NSError?)> ? completionHandler}) → void - Inserts the provided resource into the ambient cache, calling a completion handler when finished.
-
putResourceWithUrl(
NSURL url, {required NSData data, NSDate? modified, NSDate? expires, NSString? etag, required bool mustRevalidate}) → void - putResourceWithUrl:data:modified:expires:etag:mustRevalidate:
-
release(
) → void -
release
inherited
-
reloadPacks(
) → void -
Forcibly, asynchronously reloads the
packsproperty. At some point after this method is called, the pointer values of theMLNOfflinePackobjects in thepacksproperty change, even if the underlying data for these packs has not changed. If this method is called while a pack is actively downloading, the behavior is undefined. -
removePack(
MLNOfflinePack pack, {ObjCBlock< Void Function(NSError?)> ? withCompletionHandler}) → void - Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
-
resetDatabaseWithCompletionHandler(
ObjCBlock< Void Function(NSError?)> completion) → void - Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
-
respondsToSelector(
Pointer< ObjCSelector> aSelector) → bool -
respondsToSelector:
inherited
-
retain(
) → MLNOfflineStorage - retain
-
retainCount(
) → int -
retainCount
inherited
-
self$1(
) → MLNOfflineStorage - self
-
setMaximumAllowedMapboxTiles(
int maximumCount) → void - Sets the maximum number of tiles that may be downloaded and stored on the current device.
-
setMaximumAmbientCacheSize(
int cacheSize, {required ObjCBlock< Void Function(NSError?)> withCompletionHandler}) → void -
Sets the maximum ambient cache size in bytes. The default maximum cache
size is 50 MB. To disable ambient caching, set the maximum ambient cache size
to
0. Setting the maximum ambient cache size does not impact the maximum size of offline packs. -
toString(
) → String -
A string representation of this object.
inherited
-
zone(
) → Pointer< NSZone> -
zone
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
alloc(
) → MLNOfflineStorage - alloc
-
allocWithZone(
Pointer< NSZone> zone) → MLNOfflineStorage - allocWithZone:
- Returns the shared offline storage object.
-
isInstance(
ObjCObjectBase obj) → bool -
Returns whether
objis an instance of MLNOfflineStorage. -
new$(
) → MLNOfflineStorage - new