How to update an object in Realm Swift

Updating objects is just assign a value to a property within a write transaction. See our documentation. https://realm.io/docs/swift/latest/#updating-objects So you don’t need to delete and then add an object. Just assign new value to the property in write transaction like the following. let workouts = realm.objects(WorkoutsCount.self).filter(“date = %@”, removeTodaysItem) let realm = try! Realm() if … Read more

Conforming to Hashable protocol?

You’re missing the declaration: struct DateStruct: Hashable { And your == function is wrong. You should compare the three properties. static func == (lhs: DateStruct, rhs: DateStruct) -> Bool { return lhs.year == rhs.year && lhs.month == rhs.month && lhs.day == rhs.day } It’s possible for two different values to have the same hash value.