this is my code
import SwiftUI
import SwiftData
@Model
class TestItemTotal {
var name: String
init(_ name: String) {
self.name = name
}
}
struct TestItemTotalDetail: View {
var currentItem: TestItemTotal
var body: some View {
VStack {
Text(currentItem.name)
}
}
init(currentItem: TestItemTotal) {
self.currentItem = currentItem
}
}
#Preview {
var item = TestItemTotal("james qq")
return TestItemTotalDetail(currentItem: item)
}
Crash
it will crash ,when #preview use Xcode
fix Crash
Remove @Model string , it will not crash , when #preview use Xcode ,
but i can't remove @Model String , because i will to processing data by SwiftData
the crash info
I don't know how to fix this crash .