Posts

Post not yet marked as solved
2 Replies
990 Views
I'm trying to instantiate my model and I'm getting an error on the set first property import Foundation import SwiftData @Model final class PointModel { var x: CGFloat var y: CGFloat init( x: CGFloat, y: CGFloat ) { self.x = x self.y = y } } extension PointModel { static var preview: PointModel { PointModel(x: 0, y: 0) } } let point = PointModel(x: location.x, y: location.y) { get { _$observationRegistrar.access(self, keyPath: \.x) return self.getValue(for: \.x) } set { _$observationRegistrar.withMutation(of: self, keyPath: \.x) { self.setValue(for: \.x, to: newValue) **Thread 1: Fatal error: Illegal attempt to use a nil as an Attribute - x + 151.0** } } } Has anyone else experienced this problem? Maybe someone knows how to solve this?
Posted
by Nizelan.
Last updated
.