Is it possible in SwiftUI to come back to a specific view? Like when we had controllers The code was this as mention below
let arr = self.navigationController?.viewControllers
for controller in arr!{
if controller.isKind(of: ViewController.classForCoder()){
self.navigationController?.popToViewController(controller, animated: true)
}
}
Now Let suppose I have 4 Views:-> as mentioned in the code
struct View1: View {
var body: some View {
NavigationView {
NavigationLink(destination: View2()) {
Text("Navigate to View2")
}
}
}
}
struct View2: View {
var body: some View {
NavigationLink(destination: View3()) {
Text("Navigate to View3")
}
}
}
struct View3: View {
var body: some View {
NavigationLink(destination: View4()) {
Text("Navigate to View4")
}
}
}
struct View4: View {
var body: some View {
Text("4")
}
}
Is it possible to pop from View4 to View2??? "Skipping View 3" or From View3 to View 1 Likewise UIKit