I have 2 classes and a relationship from one to another... I am getting an error while runtime. Can someone help me with this issue??..
@storageRestrictions(accesses: _$backingData, initializes: _trans)
init(initialValue) {
_$backingData.setValue(forKey: \.trans, to: initialValue)
_trans = _SwiftDataNoType()
}
get {
_$observationRegistrar.access(self, keyPath: \.trans)
return self.getValue(forKey: \.trans)
}
set {
_$observationRegistrar.withMutation(of: self, keyPath: \.trans) {
self.setValue(forKey: \.trans, to: newValue)
}
}
}
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x25256ead8) Below is my class...
import SwiftData
@Model
final class Main {
var name: String
var limit: Double
@Relationship(deleteRule: .cascade)
var trans: [Child] = []
init(name: String, limit: Double, trans: [Child]) {
self.name = name
self.limit = limit
self.trans = trans
}
}
@Model
final class Child {
var trip: String
var distance: Double
init(trip: String, distance: Double) {
self.trip = trip
self.distance = distance
}
}