Anupam Mishra
Anupam Mishra

Reputation: 3588

SwiftUI : Segue navigation

I am trying to pass data from one screen to another, is it possible to create segue in swiftUI and use below method?

prepare(for segue: UIStoryboardSegue, sender: Any?)

Upvotes: 2

Views: 4154

Answers (2)

tomEngland
tomEngland

Reputation: 103

This is where @ObjectBinding comes in. If you wish to pass data from view A to view B, you would use @ObjectBinding on a struct or a class, have that struct or class conform to BindableObject with declaring a didChange property and by using Combine, publish those changes to your view via @ObjectBindable property wrapper if changes are made. Otherwise this will allow you to have a referenced-link to your object.

Upvotes: 1

Renata Faria
Renata Faria

Reputation: 515

I can't help you with the segue issue, but if you want pass data from one screen to another you can do in this way:

First: create a var in your destination

struct DestinationView : View {
    let information: InfoType
    var body: some View { ... }
}

Then when you pass this info inside your navigation button:

NavigationButton(destination: DestinationView(information: info)) {
     Text("click me")
}

Sorry for not answering exactly what you want, but hope it helps

Upvotes: 3

Related Questions