In Beta 5 SwiftData works on the vision pro, but there's a ton of bugs in general with beta 5
Post
Replies
Boosts
Views
Activity
Same for me. It seems everything needs to be optional now, and not have a default value, which makes for uglier code.
But
var text:String?
var translation:[String]?
Should work fine for you
Ok so two issues I can see here, forgive me if I'm wrong but I need to rush this answer
First up you're not using Relationships
@Model class AModel {
@Attribute(.unique) var id:String
var date:Date
@Relationship(inverse: \BModel.aModel)
var b:[BModel]
}
@Model class BModel {
@Attribute(.unique) var id:String
var date:Date
var aModel: AModel?
init() {
self.id = UUID().uuidString
self.date = Date()
}
}
Secondly, and this is something that only started happening to me in the last two betas. I found I need to insert the bModel before appending it to a property in aModel. This may not be the issue, as usually this only affects me when passing a model through in an initialiser, but worth a shot
.onAppear {
let model = BModel()
modelContext.insert(model)
a.b.append(model)
print(a.b)
}
Again, apologies if I misunderstood the question, I'm in a bit of a rush here. Let me know if I can help more