Swiftpack.co - nightwill/CLLocationManagerPublisher as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by nightwill.
nightwill/CLLocationManagerPublisher 1.0.0
An extension for CLLocationManager for supporting publishers
⭐️ 1
🕓 2 years ago
iOS macOS
.package(url: "https://github.com/nightwill/CLLocationManagerPublisher.git", from: "1.0.0")

CLLocationManagerPublisher

Usage

struct ContentView: View {

    @State private var locationPublisher = CLLocationManager.locationPublisher().first().replaceError(with: [])
    @State private var locationString = ""
    
    var body: some View {
        Text("Location \(locationString)")
            .onReceive(locationPublisher) { locations in
                locationString = locations.map(\.textDescription).joined(separator: "\n")
            }
    }
}

private extension CLLocation {

    var textDescription: String {
        String(format: "%.5f,%.5f %@", coordinate.latitude, coordinate.longitude, timestamp.description)
    }

}

GitHub

link
Stars: 1
Last commit: 2 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics