Search code examples
realmswift5

Bool and Int properties not added to Realm


I'm using Realm with Codeable. I noticed that Bool & Int attributes aren't added to the table in Realm Browser as shown in ScreenShot. How to fix this issue? enter image description here


Solution

  • To make optional int's and bool's in Realm, they must be defined as RealmOptional.

    So update your model like this

    @objcMembers class CategoryDoc: Object: Codeable {
        dynamic var name: String?
    
        let isActive = RealmOptional<Int>()
        let v = RealmOptional<Bool>()