Post

Replies

Boosts

Views

Activity

Binary operator '<' cannot be applied to two 'Date?' operands
Hey guys. I have the error: "Binary operator '<' cannot be applied to two 'Date?' operands" popping up after changing this: class TaskItem: Object, Identifiable { @Persisted(primaryKey: true) var id: ObjectId @Persisted var taskTitle: String @Persisted var taskNotes: String @Persisted var taskDate: Date = Date() @Persisted var isFinished: Bool @Persisted var taskTime: Date = Date() @Persisted var isNotificationsEnabled: Bool @Persisted var taskColor: String static func < (lhs: TaskItem, rhs: TaskItem) -> Bool { if lhs.taskDate == rhs.taskDate { return lhs.taskTitle < rhs.taskTitle } else { return lhs.taskDate < rhs.taskDate } } } to: class TaskItem: Object, Identifiable { @Persisted(primaryKey: true) var id: ObjectId @Persisted var taskTitle: String @Persisted var taskNotes: String @Persisted var taskDate: Date? = nil @Persisted var isFinished: Bool @Persisted var taskTime: Date? = nil @Persisted var isNotificationsEnabled: Bool @Persisted var taskColor: String static func < (lhs: TaskItem, rhs: TaskItem) -> Bool { if lhs.taskDate == rhs.taskDate { return lhs.taskTitle < rhs.taskTitle } else { return lhs.taskDate < rhs.taskDate } } } Please help as fast as possible, since there is almost no more time left for the swift student challenge.
5
0
2.0k
Apr ’23