SwiftData and Canvas Previews confusion
Has anyone gotten the SwiftData, SwiftUI, and Live Canvas Preview features to work in conjunction with each other? I can get the previews working if I don't use SwiftData, but when I try to have a view that uses SwiftData, Xcode seems to error out at times for non-obvious reasons, and I'm not sure if there's a recommended way to fix those problems.
I've been trying this approach with limited success:
https://stackoverflow.com/questions/76543560/how-to-preload-data-into-swiftdata-model
as sometimes my data model classes (which have
@Relationships
to other models) end up causing Xcode errors.Stack Overflow
How to preload data into SwiftData model?
import Foundation
import SwiftData
@Model class Example: {
let name: String
let type: String
init(name: String, type: String) {
self.name = name
self.type = type
}...
1 Reply
@Community Coach any ideas?