TKRegionManager

public class TKRegionManager : NSObject
  • Declaration

    Swift

    @objc
    public static let shared: TKRegionManager
  • Declaration

    Swift

    @objc
    public static let UpdatedRegionsNotification: NSNotification.Name
  • Declaration

    Swift

    public func loadRegionsFromCache()
  • Declaration

    Swift

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

    Swift

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

    Swift

    @objc
    public var regionsHash: NSNumber? { get }

Updating regions data

  • Declaration

    Swift

    @objc(updateRegionsFromData:)
    public func updateRegions(from data: Data)
  • Declaration

    Swift

    public static var cacheURL: URL { get }
  • Declaration

    Swift

    public static func readLocalCache() -> Data?
  • 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.

  • Declaration

    Swift

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

    Swift

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

    Swift

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

    Swift

    public static func sortedFlattenedModes(_ modes: [[TKRegion.RoutingMode]]) -> [TKRegion.RoutingMode]

Testing coordinates

  • 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

    @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

  • 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