1

I'm using RealmSwift in Xcode 10.2 and Swift4.2.

I made following code.

import Foundation
import RealmSwift

enum MyEnum {
    case enum1
    case enum2
    case enum3
}

class MyClass: Object {
    @objc dynamic var title = ""
    @objc dynamic var myEnum: MyEnum?
}

Following error has been occurred when I build.

'dynamic' property 'myEnum' must also be '@objc'

As you can see, @objc is already added for myEnum variable, so I'm confused. This error is occurred only for Enum variable.

Would you give me any solutions or advices ?

ken
  • 648
  • 2
  • 6
  • 16
  • 1
    Only enums with `Int`(or other integer) raw value type can be represented in `Objective C` and marked with `@objc`. – user28434'mstep Apr 23 '19 at 08:37
  • 2
    Possible duplicate of [Using enum as property of Realm model](https://stackoverflow.com/questions/29123245/using-enum-as-property-of-realm-model) – Anand Apr 23 '19 at 08:39

0 Answers0