Good morning all,
I am writing an app using SwiftData
. I have a enum type:
enum WhenToPay: Identifiable, CaseIterable, CustomStringConvertible, Codable {
var id: Self { self }
case midMonth
case endOfMonth
var description: String {
switch self {
case .midMonth:
return "Mid Month"
case .endOfMonth:
return "End Of Month"
}
}
}
My SwiftData
model is as follows:
@Model
class BillSD {
var name: String = ""
var amount: Double = 0.0
var paid: Bool = false
var month: BillMonth = .january
var whenToPay: WhenToPay = .endOfMonth
@Relationship(.nullify, inverse: \SectionSD.bills) var section: SectionSD? = nil
init(name: String, amount: Double, paid: Bool, month: BillMonth, whenToPay: WhenToPay) {
self.name = name
self.amount = amount
self.paid = paid
self.month = month
self.whenToPay = whenToPay
}
}
I get the folowing error that I have no idea why. As long as the Enum
conforms to Codable
than I should be able to use it within my SwiftData
model. But the model gives me this error, can anyone provide help with this:
Type 'Any' has no member 'endOfMonth'
then under that error it says In expansion of macro 'Model' here
Thanks
Taz