- Using new concurrency swift model around CoreLocation
- Streaming current locations asynchronously
- Customizable in terms of accuracy
- Errors handling
@EnvironmentObject var model: LMViewModel
Task{
do{
try await viewModel.start()
}catch{
self.error = error.localizedDescription
}
}
@ViewBuilder
var coordinatesTpl: some View{
List(viewModel.locations, id: \.hash) { location in
Text("\(location.coordinate.longitude), \(location.coordinate.latitude)")
}
}
///Access was denied by user
case accessIsNotAuthorized
public protocol ILocationManagerViewModel: ObservableObject{
/// List of locations
@MainActor
var locations : [CLLocation] { get }
/// Start streaming locations
func start() async throws
/// Stop streaming locations
func stop()
}
if you are using the simulator don't forget to simulate locations
- You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
- Go to Product > Build Documentation or ⌃⇧⌘ D