There is a few old thread that discuss the usage of Enums in Realm, and I adopted one them which works fine but I want to make sure that that is still the recommended way of doing it.
Is the following code the current-recommended way to use Enums with Realm?
Realm Object
enum SeatPreference: String {
case Window
case Middle
case Aisle
}
class Ticket:Object{
@objc private dynamic var preference = SeatPreference.Window.rawValue
var seatPreference: SeatPreference {
get { return SeatPreference(rawValue: preference)! }
set { preference = newValue.rawValue }
}
}
Usage:
ticket.seatPreference = .Middle
Again, everything works fine, I just want someone to confirm that there is still not a better way of doing it.