Last active
October 28, 2024 16:02
-
-
Save takoikatakotako/d694f238e324cfb215a76a1a58b74c23 to your computer and use it in GitHub Desktop.
Identifiableに適合していないStructでListを使う
This file contains 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 pokemons: [Pokemon] = [ | |
Pokemon(name: "snorlax", type: "normal"), | |
Pokemon(name: "ditto", type: "normal"), | |
Pokemon(name: "psyduck", type: "water"), | |
Pokemon(name: "pikachu", type: "electric"), | |
] | |
var body: some View { | |
List { | |
ForEach(0..<pokemons.count, id: \.self) { index in | |
Text("\(pokemons[index].name)") | |
} | |
} | |
} | |
} |
This file contains 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 Pokemon { | |
let name: String | |
let type: String | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment