回答編集履歴

2

軽微な修正

2021/05/30 14:06

投稿

ko-ru
ko-ru

スコア27

test CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  struct ContentView: View {
18
18
 
19
- @State var words = ["hoge", "hogehoge"]
19
+ @State var words = ["", ""]
20
20
 
21
21
  var body: some View {
22
22
 
@@ -24,13 +24,13 @@
24
24
 
25
25
  Button("Add") {
26
26
 
27
- self.words.append("test")
27
+ self.words.append("")
28
28
 
29
29
  }
30
30
 
31
31
  List {
32
32
 
33
- ForEach(0..<words.count, id: .self) { i in
33
+ ForEach(words.indices, id: .self) { i in
34
34
 
35
35
  TextField("", text: self.$words[i])
36
36
 

1

軽微な修正

2021/05/30 14:06

投稿

ko-ru
ko-ru

スコア27

test CHANGED
@@ -32,7 +32,7 @@
32
32
 
33
33
  ForEach(0..<words.count, id: .self) { i in
34
34
 
35
- TextField("", text: self.$words[i]) // <-- and the binding
35
+ TextField("", text: self.$words[i])
36
36
 
37
37
  }
38
38