**Hi, hopefully you can help me with this swiftUI code? I have created a Map App which will show a route via a ManPolyLine (see the code).
Whilst I can print the route via the (in the code below) var _ = print("ROUTE = (route.steps.map { $0.instructions }.filter { !$0.isEmpty })")
I CANNOT create a variable for the route it prints? I need to do this so I can create a .sheet (which is shown), but cannot Access a Variable to List the route details!
Help would be most appreciated, TIA
(The pertinent part of the code below)**
===========================================
@State private var route: MKRoute?
@State private var myRoute: [String] = []
@State private var selectedResult: MKMapItem?
@State private var position: MapCameraPosition = .automatic
Map(position: $position, selection: $selectedResult)
{
ForEach(searchResults, id: \.self) {
result in
Marker(item: result)
}
.annotationTitles(.hidden)
UserAnnotation()
if let route {
MapPolyline(route)
.stroke(.blue, lineWidth: 5)
var myRoute = route.steps.map { $0.instructions }.filter { !$0.isEmpty }
var _ = print("ROUTE = \(route.steps.map { $0.instructions }.filter { !$0.isEmpty })")
var _ = print("COUNT = \(myRoute.count)")
}
}
===========================================