I clarified this model a bit.
enum Thing: String { case Thing1 case Thing2 case Thing3 }
then in my Realm class object:
class myClass : Object { private dynamic var privateThing = Thing.Thing1.rawValue var thing: Thing { get { return Thing(rawValue: privateThing)! } set { privateThing = newValue.rawValue } } }
It allows us to write
myClassInstance.thing = .Thing1
(storing "Thing1" in privateThing) but prevents input
myClassInstance.privateThing = "Thing4"
which is not a valid value, thus preserving data integrity.
Stephen Watson Nov 02 '15 at 15:11 2015-11-02 15:11
source share