pableiros pableiros - 4 months ago 61
Swift Question

RealmSwift List requires that String inherit from Object

I'm trying to have a list of Strings on

RealmSwift
like this:

import Foundation
import RealmSwift

// V1
class foo: Object {
let strings = List<String>()
}


But I get this error:


'List' requires that 'String' inherit from 'Object'


Is anyway to create a list of Strings without creating an entire class with one String property in
Realm
?

Answer

Arrays of primitives are not yet supported by Realm Swift. You can subscribe to GitHub issue 1120 to be notified when we add support. Until then you'll need to wrap the string in a class that derives from RealmSwift.Object.

Comments