CLLocationCoordinate2D

public struct CLLocationCoordinate2D : CustomDebugStringConvertible, CustomStringConvertible, Sendable

Represents a geographic coordinate in degrees. Apple Documentation

CustomStringConvertible

  • A user-friendly description of the coordinate.

    Declaration

    Swift

    public var description: String { get }

CustomDebugStringConvertible

  • A debug-friendly description of the coordinate.

    Declaration

    Swift

    public var debugDescription: String { get }

CLLocationCoordinate2D Extensions

  • Calculates the distance to another coordinate using the haversine formula.

    Declaration

    Swift

    func distance(to other: CLLocationCoordinate2D) -> CLLocationDistance

    Parameters

    other

    The destination coordinate

    Return Value

    Distance in meters

  • Calculates the bearing to another coordinate.

    Declaration

    Swift

    func bearing(to other: CLLocationCoordinate2D) -> CLLocationDirection

    Parameters

    other

    The destination coordinate

    Return Value

    Bearing in degrees (0-360)

  • Checks if this coordinate is valid (within acceptable latitude/longitude ranges).

    Declaration

    Swift

    var isValid: Bool { get }