Protocols

The following protocols are available globally.

  • This protocol shall be implemented by any cache used in MapCache.

    See also

    Main Readme page
    See more

    Declaration

    Swift

    public protocol MapCacheProtocol
  • RegionDownloaderDelegate provides callbacks for monitoring the progress of a tile region download.

    Conform to this protocol to receive notifications about download progress, individual tile results, and lifecycle events. All methods have default empty implementations provided via a protocol extension, making each callback optional — implement only the ones you need.

    Usage Example

    class MyViewController: UIViewController, RegionDownloaderDelegate {
    
        func startDownload() {
            let downloader = RegionDownloader(forRegion: region, mapCache: cache)
            downloader.delegate = self
            downloader.start()
        }
    
        // Update a progress bar on percentage changes.
        func regionDownloader(_ downloader: RegionDownloader, didDownloadPercentage percentage: Double) {
            DispatchQueue.main.async {
                self.progressView.progress = Float(percentage / 100.0)
            }
        }
    
        // Show final counts when done.
        func regionDownloader(_ downloader: RegionDownloader, didFinishDownload tilesDownloaded: TileNumber) {
            DispatchQueue.main.async {
                self.label.text = "Done: \(tilesDownloaded) tiles"
            }
        }
    }
    
    See more

    Declaration

    Swift

    public protocol RegionDownloaderDelegate : AnyObject