ソースを参照

fix: re-enable UUID-based for-each by regenerating the uuid list when calling autosave()

Sam Jaffe 2 週間 前
コミット
6e228bd5b7
1 ファイル変更2 行追加1 行削除
  1. 2 1
      Todos/View/ContentView.swift

+ 2 - 1
Todos/View/ContentView.swift

@@ -19,7 +19,7 @@ struct ContentView: View {
   var body: some View {
     NavigationSplitView {
       List(selection: $selection) {
-        ForEach(items, id: \.self) { item in
+        ForEach(items, id: \.uuid) { item in
           NavigationLink(value: item) {
             Text(item.name)
           }.swipeActions(content: {
@@ -67,6 +67,7 @@ struct ContentView: View {
   }
 
   private func autosave() {
+    items.forEach({ $0.uuid = UUID() })
     if inPreview {
       // This isn't great, but we shouldn't be running this in a preview
       // environment in the first place, so w/e.