With the following code:
@Model
final class Item {
var data: [Data]
init(data: [Data]) {
self.data = data
}
}
@Model
final class Data {
var contents: String
init(contents: String) {
self.contents = contents
}
}
..
let data = Data(contents: "yo")
let newItem = Item(timestamp: Date(), data: [data])
print(newItem.data) // <-- exception thrown here
I get an exception on the print line when accessing the .data
field:
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1f379a29c)
Note that if I first save newItem to the context the exception is not thrown, i.e.:
let data = Data(contents: "yo")
let newItem = Item(timestamp: Date(), data: [data])
modelContext.insert(newItem)
print(newItem.data) // <-- no exception
Unfortunately the exception is cryptic so I can't tell what's wrong.
Xcode version 15.0 beta 8 (15A5229m)
macOS Sonoma beta 14.0 (23A5337a)