---
title: "MTTileURLTemplate | Mobile sdk | Mobile sdk ios | Ios"
description: "A helper struct for validating and building tile URLs from string templates."
---

> 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.

# MTTileURLTemplate

```
public struct MTTileURLTemplate
```

A helper struct for validating and building tile URLs from string templates.

-   `[isValid(template:)](#/s:11MapTilerSDK17MTTileURLTemplateV7isValid8templateSbSS_tFZ)`
    
    Checks if a given template string contains the required minimum tokens.
    
    #### Declaration
    
    Swift
    
    ```
    public static func isValid(template: String) -> Bool
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>template</em></code></td><td><div><p>The URL template string.</p></div></td></tr></tbody></table>
    
    #### Return Value
    
    `true` if it contains `{z}`, `{x}`, and either `{y}` or `{-y}`.
    
-   `[buildURL(template:z:x:y:scheme:)](#/s:11MapTilerSDK17MTTileURLTemplateV8buildURL8template1z1x1y6scheme10Foundation0G0VSgSS_S3iAA19MTOfflineTileSchemeOtFZ)`
    
    Builds a full tile URL from a template string for given coordinates and scheme.
    
    This method seamlessly handles the `{-y}` token which implies a TMS-style inverted Y-axis, even if the `scheme` passed is explicitly XYZ. If `{-y}` is present, it will invert the Y coordinate.
    
    #### Declaration
    
    Swift
    
    ```
    public static func buildURL(template: String, z: Int, x: Int, y: Int, scheme: MTOfflineTileScheme = .xyz) -> URL?
    ```
    
    #### Parameters
    
    <table class="graybox"><tbody><tr><td><code><em>template</em></code></td><td><div><p>The URL template string (e.g., <code>https://example.com/tiles/{z}/{x}/{y}.pbf</code>).</p></div></td></tr><tr><td><code><em>z</em></code></td><td><div><p>The zoom level.</p></div></td></tr><tr><td><code><em>x</em></code></td><td><div><p>The X coordinate.</p></div></td></tr><tr><td><code><em>y</em></code></td><td><div><p>The Y coordinate.</p></div></td></tr><tr><td><code><em>scheme</em></code></td><td><div><p>The coordinate scheme (<code>.xyz</code> or <code>.tms</code>).</p></div></td></tr></tbody></table>
    
    #### Return Value
    
    A valid `URL` if the template is correctly formatted, `nil` otherwise.
