Created
October 24, 2024 01:53
-
-
Save takoikatakotako/62204695cace4a478a097d8d4445a2f5 to your computer and use it in GitHub Desktop.
画面遷移時に値を渡す
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| let fruits = ["Apple", "Banana", "Orange", "Grape", "Cherry", "Peach"] | |
| var body: some View { | |
| NavigationView { | |
| List(fruits, id: \.self) { fruit in | |
| NavigationLink(destination: SecondView(fruit: fruit)) { | |
| Text(fruit) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| #Preview { | |
| ContentView() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct SecondView: View { | |
| let fruit: String | |
| var body: some View { | |
| Text(fruit) | |
| } | |
| } | |
| #Preview { | |
| SecondView(fruit: "Apple") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment