質問編集履歴

1

エラー発生個所が間違っておりました。

2024/05/16 05:55

投稿

takopu
takopu

スコア0

test CHANGED
File without changes
test CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
 
7
7
  ### 発生している問題・分からないこと
8
- modelContext.insert(newItem)を実行すると配列「children」のデータがParentにセットできないでエラーになります。
8
+ Parentに子データの配列「children」を渡そうとするとParentにセットできないでエラーになります。
9
9
  そもそものアプローチの仕方が間違っているのでしょうか?
10
10
 
11
11
 
@@ -94,8 +94,8 @@
94
94
 
95
95
 
96
96
  Button("Add") {
97
- let newItem = Parent(hiduke: txtHiduke, kion: txtKion, children: children)
97
+ let newItem = Parent(hiduke: txtHiduke, kion: txtKion, children: children) //←エラー発生個所
98
- modelContext.insert(newItem) //←エラー発生個所
98
+ modelContext.insert(newItem)
99
99
  }
100
100
  }
101
101
  }