---
title: "MTOfflinePack | Mobile sdk | Mobile sdk ios | Ios"
description: "Represents a downloadable offline region."
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# MTOfflinePack

```
public actor MTOfflinePack
```

Represents a downloadable offline region.

-   `[id](#/s:11MapTilerSDK13MTOfflinePackC2idSSvp)`
    
    The unique identifier of the pack.
    
    #### Declaration
    
    Swift
    
    ```
    public nonisolated let id: String
    ```
    
-   `[region](#/s:11MapTilerSDK13MTOfflinePackC6regionAA0D16RegionDefinitionVvp)`
    
    The region definition of the pack.
    
    #### Declaration
    
    Swift
    
    ```
    public nonisolated let region: MTOfflineRegionDefinition
    ```
    
-   `[progress](#/s:11MapTilerSDK13MTOfflinePackC8progressAA0dE8ProgressVvp)`
    
    The current progress of the pack download.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var progress: MTOfflinePackProgress { get }
    ```
    
-   `[metadata](#/s:11MapTilerSDK13MTOfflinePackC8metadataAA0dE8MetadataVvp)`
    
    The metadata object linking state and region.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var metadata: MTOfflinePackMetadata { get }
    ```
    
-   `[delegate](#/s:11MapTilerSDK13MTOfflinePackC8delegateAA0D16DownloadDelegate_pSgvp)`
    
    An optional delegate to receive download notifications.
    
    #### Declaration
    
    Swift
    
    ```
    public weak var delegate: MTOfflineDownloadDelegate?
    ```
    
-   `[isProgressReportingEnabled](#/s:11MapTilerSDK13MTOfflinePackC26isProgressReportingEnabledSbvp)`
    
    If true, download progress updates will be reported to the delegate. Defaults to false.
    
    #### Declaration
    
    Swift
    
    ```
    public var isProgressReportingEnabled: Bool
    ```
    
-   `[state](#/s:11MapTilerSDK13MTOfflinePackC5stateAA0dE5StateOvp)`
    
    The current state of the pack download.
    
    #### Declaration
    
    Swift
    
    ```
    public private(set) var state: MTOfflinePackState { get set }
    ```
    
-   `[expiresAt](#/s:11MapTilerSDK13MTOfflinePackC9expiresAt10Foundation4DateVvp)`
    
    The date when the pack expires.
    
    #### Declaration
    
    Swift
    
    ```
    public var expiresAt: Date { get }
    ```
    
-   `[isExpired](#/s:11MapTilerSDK13MTOfflinePackC9isExpiredSbvp)`
    
    Returns true if the pack has passed its expiration date.
    
    #### Declaration
    
    Swift
    
    ```
    public var isExpired: Bool { get }
    ```
    
-   `[setDelegate(_:)](#/s:11MapTilerSDK13MTOfflinePackC11setDelegateyyAA0d8DownloadG0_pSgF)`
    
    Sets the delegate to receive download notifications.
    
    #### Declaration
    
    Swift
    
    ```
    public func setDelegate(_ delegate: MTOfflineDownloadDelegate?)
    ```
    
-   `[setProgressReportingEnabled(_:)](#/s:11MapTilerSDK13MTOfflinePackC27setProgressReportingEnabledyySbF)`
    
    Enables or disables progress reporting.
    
    #### Declaration
    
    Swift
    
    ```
    public func setProgressReportingEnabled(_ isEnabled: Bool)
    ```
    
-   `[init(region:context:)](#/s:11MapTilerSDK13MTOfflinePackC6region7contextAcA0D16RegionDefinitionV_10Foundation4DataVSgtcfc)`
    
    Initializes a new pack to begin downloading.
    
    #### Declaration
    
    Swift
    
    ```
    public init(
        region: MTOfflineRegionDefinition,
        context: Data? = nil
    )
    ```
    

[](#/Static%20Methods)

### Static Methods

-   `[createPack(region:context:)](#/s:11MapTilerSDK13MTOfflinePackC06createE06region7contextAcA0D16RegionDefinitionV_10Foundation4DataVSgtYaKFZ)` Asynchronous
    
    Creates a new offline pack and initializes its on-disk storage and metadata.
    
    Throws
    
    An error if directory creation or metadata persistence fails.
    
    #### Declaration
    
    Swift
    
    ```
    public static func createPack(
        region: MTOfflineRegionDefinition,
        context: Data? = nil
    ) async throws -> MTOfflinePack
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>region</em></code></td><td><div><p>The definition of the region to be downloaded.</p></div></td></tr><tr><td><code><em>context</em></code></td><td><div><p>Optional custom data (e.g., JSON) to attach to the pack metadata.</p></div></td></tr></tbody></table>
    
    #### Return Value
    
    A newly initialized `MTOfflinePack`.
    
-   `[estimateSize(region:)](#/s:11MapTilerSDK13MTOfflinePackC12estimateSize6regionAA11MTPackStatsVAA0D16RegionDefinitionV_tYaKFZ)` Asynchronous
    
    Estimates the pack size for a given region definition.
    
    Throws
    
    An error if style fetching or parsing fails.
    
    #### Declaration
    
    Swift
    
    ```
    public static func estimateSize(region: MTOfflineRegionDefinition) async throws -> MTPackStats
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>region</em></code></td><td><div><p>The definition of the region to estimate.</p></div></td></tr></tbody></table>
    
    #### Return Value
    
    An `[MTPackStats](https://docs.maptiler.com/mobile-sdk/ios/api/Structs/MTPackStats/)` object containing the estimates.
    
-   `[packs()](#/s:11MapTilerSDK13MTOfflinePackC5packsSayACGyYaKFZ)` Asynchronous
    
    Retrieves all offline packs currently stored on disk. The packs are stably sorted by their creation date (oldest first).
    
    #### Declaration
    
    Swift
    
    ```
    public static func packs() async throws -> [MTOfflinePack]
    ```
    
    #### Return Value
    
    An array of `MTOfflinePack` instances.
    
-   `[cleanupExpiredPacks()](#/s:11MapTilerSDK13MTOfflinePackC19cleanupExpiredPacksyyYaKFZ)` Asynchronous
    
    Cleans up packs that have been expired for longer than the grace period. This permanently deletes the packs and their files from the disk.
    
    #### Declaration
    
    Swift
    
    ```
    public static func cleanupExpiredPacks() async throws
    ```
    
-   `[removeAll()](#/s:11MapTilerSDK13MTOfflinePackC9removeAllyyYaKFZ)` Asynchronous
    
    Deletes all offline packs currently stored on disk.
    
    #### Declaration
    
    Swift
    
    ```
    public static func removeAll() async throws
    ```
    

[](#/Download%20Actions)

### Download Actions

-   `[download(useBackground:)](#/s:11MapTilerSDK13MTOfflinePackC8download13useBackgroundySb_tYaKF)` Asynchronous
    
    Starts the download process for this pack. This generates the necessary manifest based on the pack’s region definition and then begins downloading all required resources.
    
    Note
    
    When `useBackground` is `true`, this method returns after enqueuing tasks. The pack becomes loadable only after a later `.completed` state change.
    
    #### Declaration
    
    Swift
    
    ```
    public func download(useBackground: Bool = false) async throws
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>useBackground</em></code></td><td><div><p>If true, the download will be enqueued in a background URLSession.</p></div></td></tr></tbody></table>
    
-   `[resume(useBackground:)](#/s:11MapTilerSDK13MTOfflinePackC6resume13useBackgroundySb_tYaKF)` Asynchronous
    
    Resumes a previously paused or failed download.
    
    #### Declaration
    
    Swift
    
    ```
    public func resume(useBackground: Bool = false) async throws
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>useBackground</em></code></td><td><div><p>If true, the download will resume in a background URLSession.</p></div></td></tr></tbody></table>
    
-   `[refresh(useBackground:)](#/s:11MapTilerSDK13MTOfflinePackC7refresh13useBackgroundySb_tYaKF)` Asynchronous
    
    Refreshes an expired pack, validating or updating its resources and resetting its expiration limit.
    
    #### Declaration
    
    Swift
    
    ```
    public func refresh(useBackground: Bool = false) async throws
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>useBackground</em></code></td><td><div><p>If true, the download will be enqueued in a background URLSession.</p></div></td></tr></tbody></table>
    
-   `[cancel()](#/s:11MapTilerSDK13MTOfflinePackC6cancelyyYaF)` Asynchronous
    
    Cancels the ongoing download of the entire pack.
    
    #### Declaration
    
    Swift
    
    ```
    public func cancel() async
    ```
    
-   `[pause()](#/s:11MapTilerSDK13MTOfflinePackC5pauseyyYaF)` Asynchronous
    
    Pauses the ongoing download of the entire pack.
    
    #### Declaration
    
    Swift
    
    ```
    public func pause() async
    ```
    
-   `[cancelAsset(id:)](#/s:11MapTilerSDK13MTOfflinePackC11cancelAsset2idySS_tYaF)` Asynchronous
    
    Cancels the download of a specific asset within the pack.
    
    #### Declaration
    
    Swift
    
    ```
    public func cancelAsset(id: String) async
    ```
    
-   `[remove()](#/s:11MapTilerSDK13MTOfflinePackC6removeyyYaKF)` Asynchronous
    
    Deletes the offline pack. This stops any ongoing downloads and removes all associated files and metadata from disk.
    
    #### Declaration
    
    Swift
    
    ```
    public func remove() async throws
    ```
