Post

Replies

Boosts

Views

Activity

Reply to SwiftData Unexpected type for CompositeAttribute
When I remove Codable support from SomeStruct, I get this error. Note that "Location" in the image is "SomeStruct" in the example above. I'm intending to inline the storage for Some Struct into Foo, rather than have a relationship. The struct is only a collection of Doubles. It gets used in multiple Model objects, in some cases for multiple variables. Creating it as a relationship requires that Location have storage for a pointer to the inverse. I don't see how that could work if some class has two separate variables which each have a relationship to the same class. Also, this data is really part of the Foo class in the example, and splitting it out into a separate table doesn't make sense. Thanks for the engagement.
Dec ’23
Reply to SwiftData Unexpected type for CompositeAttribute
FWIW, here's the code that actually throws the error from the above model. var sharedModelContainer: ModelContainer = { let schema = Schema([ foo.self, ]) let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false) do { let container = try ModelContainer(for: schema, configurations: [modelConfiguration]) container.mainContext.autosaveEnabled = true print("DragAlert.sharedModelContainer initialized.") return container } catch { fatalError("Could not create ModelContainer: \(error)") } }()
Dec ’23