79615074

Date: 2025-05-10 02:14:34
Score: 1
Natty:
Report link

Saving the context fixed the issue:

Button("Add") {
    let newModel = MyModel(name: "Example")
    modelContext.insert(newModel)
    try? modelContext.save() // Added this line.
    selectedModel = newModel
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: MohAliBou