Same issue toady. FB11860973
Post
Replies
Boosts
Views
Activity
Same issue!
I get this error too, so the Relation isn't handled properly, so I set it through the association object, and the error goes away:
@Model class School {
@Relationship(deleteRule: .cascade)
var students: [Student] = []
init() {}
}
@Model class Student {
@Relationship(inverse: \School.students)
var school: School
init(school: School) {
self.school = school
}
}
let school = School()
modelContext.insert(school)
let student = Student(school: school)
school.students.append(student) // <-- this works!
try modelContext.save()