Not sure what I'm doing wrong here. I'm taking this opportunity to add persistence to an app that hadn't had it yet.
I followed the session advice but I get this crash when running it:
SwiftData/BackingData.swift:201: Fatal error: expected attribute to be Codable
The crash is on this line:
modelContext.insert(RentSplitDataModel())
The object being created and inserted there is simple and the compiler confirms it does conform to Codable
:
https://github.com/KyLeggiero/Rent-Split-for-iOS/blob/feature/MVP/Shared/Model/RentSplitDataModel.swift
Start small .... not sure what
MoneySplitter
in your code is.@newwbee it's open-source. MoneySplitter is a simple struct with a lot of extension functions and Codable conformance: https://github.com/KyLeggiero/RentSplitTools/blob/765c748ff08e2fd0d4a1c00e8440f7ac3c6d703c/Sources/RentSplitTools/MoneySplitter.swift
Couldn't find a place where it says
MoneySplitter
conforms toCodable
.