Post

Replies

Boosts

Views

Activity

Reply to SwiftData multiple loop entries not inserting
You have a single Category object that you update inside the loop instead of creating a new category for each iteration. Remove the category property and change your loop to something like this for index in 0..<model.dataTable!.rows.count { let row = model.dataTable!.rows[index] let name = row["Catagory"] as! String let category = Category(id: UUID(), name: name, instrumen: [[) context.insert(catagory) print(catagory.name) }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’24