TKRegionManager

public class TKRegionManager : NSObject

Undocumented

  • Undocumented

    Declaration

    Swift

    @objc
    public static let shared: TKRegionManager
  • loadRegionsFromCache() Asynchronous

    Undocumented

    Declaration

    Swift

    @MainActor
    public func loadRegionsFromCache() async
  • Undocumented

    Declaration

    Swift

    @objc
    public var hasRegions: Bool { get }
  • Undocumented

    Declaration

    Swift

    @objc
    public var regions: [TKRegion] { get }
  • Undocumented

    Declaration

    Swift

    @objc
    public var regionsHash: NSNumber? { get }

Updating regions data

  • Undocumented

    Declaration

    Swift

    public static var cacheURL: URL { get }
  • Undocumented

    Declaration

    Swift

    public static func readLocalCache() -> Data?
  • Undocumented

    Declaration

    Swift

    public static func saveToCache(_ data: Data)

Getting mode details

  • Declaration

    Swift

    @objc
    public func title(forModeIdentifier mode: String) -> String?

    Parameters

    mode

    The mode identifier for which you want the title

    Return Value

    The localized title as defined by the server

  • Declaration

    Swift

    @objc
    public func subtitle(forModeIdentifier mode: String) -> String?

    Parameters

    mode

    The mode identifier for which you want the title

    Return Value

    The localized subtitle as defined by the server

  • Declaration

    Swift

    @objc
    public func websiteURL(forModeIdentifier mode: String) -> URL?

    Parameters

    mode

    The mode identifier for which you want the official website URL

    Return Value

    The URL as defined by the server

  • Declaration

    Swift

    @objc
    public func color(forModeIdentifier mode: String) -> TKColor?

    Parameters

    mode

    The mode identifier for which you want the official color

    Return Value

    The color as defined by the server

  • Declaration

    Swift

    @objc
    public func modeIdentifierIsRequired(_ mode: String) -> Bool

    Return Value

    If specified mode identifier is required and can’t get disabled.

  • Declaration

    Swift

    @objc(impliedModeIdentifiers:)
    public func impliedModes(byModeIdentifer mode: String) -> [String]

    Return Value

    List of modes that this mode implies, i.e., enabling the specified modes should also enable all the returned modes.

  • Declaration

    Swift

    @objc(dependentModeIdentifiers:)
    public func dependentModeIdentifier(forModeIdentifier mode: String) -> [String]

    Return Value

    List of modes that are dependent on this mode, i.e., disabling this mode should also disable all the returned modes.

  • Undocumented

    Declaration

    Swift

    public func remoteImageIsTemplate(forModeIdentifier mode: String) -> Bool
  • Undocumented

    Declaration

    Swift

    public func remoteImageIsBranding(forModeIdentifier mode: String) -> Bool
  • Undocumented

    Declaration

    Swift

    @objc(imageURLForModeIdentifier:ofIconType:)
    public func imageURL(forModeIdentifier mode: String?, iconType: TKStyleModeIconType) -> URL?
  • Undocumented

    Declaration

    Swift

    public static func sortedModes(in regions: [TKRegion]) -> [TKRegion.RoutingMode]

Testing coordinates

  • Undocumented

    Declaration

    Swift

    @objc(coordinateIsPartOfAnyRegion:)
    public func coordinateIsPartOfAnyRegion(_ coordinate: CLLocationCoordinate2D) -> Bool
  • Used to check if user can route in that area.

    Declaration

    Swift

    @objc(mapRectIntersectsAnyRegion:)
    public func mapRectIntersectsAnyRegion(_ mapRect: MKMapRect) -> Bool

Getting regions by coordinates, etc.

  • Declaration

    Swift

    @objc(regionContainingCoordinateRegion:)
    public func region(containing region: MKCoordinateRegion) -> TKRegion

    Return Value

    A matching local region or the shared instance of TKInternationalRegion if no local region contains this coordinate region.

  • Determines the local (non-international) regions for the coordinate pair

    Declaration

    Swift

    @objc(localRegionsForStart:andEnd:)
    public func localRegions(start: CLLocationCoordinate2D, end: CLLocationCoordinate2D) -> [TKRegion]

    Parameters

    start

    A valid coordinate

    end

    Another valid coordinate

    Return Value

    An array of either A) no element (if both coordinates are in the international region), B) one element (if both coordinates are in the the same region, or C) two elements (a local region for the start and one for the end coordinates).

  • Declaration

    Swift

    @objc(localRegionsOverlappingCoordinateRegion:)
    public func localRegions(overlapping region: MKCoordinateRegion) -> [TKRegion]

    Return Value

    Local regions that overlap with the provided coordinate region. Can be empty.

  • Declaration

    Swift

    @objc(localRegionsContainingCoordinate:)
    public func localRegions(containing coordinate: CLLocationCoordinate2D) -> Set<TKRegion>

    Parameters

    coordinate

    A coordinate

    Return Value

    The local (non-international) regions intersecting with the provided coordinate

  • Declaration

    Swift

    @available(*, deprecated, renamed: "localRegion(code:﹚")
    @objc(localRegionWithName:)
    public func localRegion(named name: String) -> TKRegion?

    Parameters

    name

    A region code

    Return Value

    The local (non-international) region matching the provided code

  • Declaration

    Swift

    public func localRegion(code: String) -> TKRegion?

    Parameters

    code

    A region code

    Return Value

    The local (non-international) region matching the provided code

  • Determines a region (local or international) for the coordinate pair

    Declaration

    Swift

    @objc(regionContainingCoordinate:andOther:)
    public func region(containing first: CLLocationCoordinate2D, _ second: CLLocationCoordinate2D) -> TKRegion

    Parameters

    first

    A valid coordinate

    second

    Another valid coordinate

    Return Value

    A local region if both lie within the same or the shared international region instance.

  • Declaration

    Swift

    @objc(timeZoneForCoordinate:)
    public func timeZone(for coordinate: CLLocationCoordinate2D) -> TimeZone?

    Parameters

    coordinate

    A valid coordinate

    Return Value

    The time zone of a matching region for this coordinate. Will return nil if the coordinate falls outside any supported region.

  • Find city closest to provided coordinate, in same region

    Declaration

    Swift

    @objc(cityNearestToCoordinate:)
    public func city(nearestTo target: CLLocationCoordinate2D) -> TKRegion.City?

    Parameters

    target

    Coordinate for which to find closest city

    Return Value

    Nearest City

  • Fetched the list of regions and updates TKRegionManager‘s cache

    Equivalent to updateRegions(forced:) async throws, but ignores the error.

    Recommended to call from the application delegate.

    Declaration

    Swift

    public func updateRegions(forced: Bool = false)

    Parameters

    forced

    Set true to force overwriting the internal cache

  • Undocumented

    Declaration

    Swift

    public func requireRegions(completion: @escaping (Result<Void, Error>) -> Void)
  • requireRegions() Asynchronous

    Undocumented

    Declaration

    Swift

    @MainActor
    public func requireRegions() async throws
  • fetchRegions(forced:) Asynchronous

    Fetched the list of regions and updates TKRegionManager‘s cache

    Equivalent to updateRegions(forced:).

    Recommended to call from the application delegate.

    Declaration

    Swift

    @MainActor
    public func fetchRegions(forced: Bool) async throws

    Parameters

    forced

    Set true to force overwriting the internal cache

Convenience methods

  • requireRegion(for:) Asynchronous

    Undocumented

    Declaration

    Swift

    @MainActor
    public func requireRegion(for coordinate: CLLocationCoordinate2D) async throws -> TKRegion
  • requireRegion(for:) Asynchronous

    Undocumented

    Declaration

    Swift

    @MainActor
    public func requireRegion(for coordinateRegion: MKCoordinateRegion) async throws -> TKRegion