Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RealmSwift List requires that String inherit from Object

Tags:

swift

realm

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?

like image 721
pableiros Avatar asked Aug 03 '16 15:08

pableiros


1 Answers

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.

like image 168
bdash Avatar answered Oct 14 '22 02:10

bdash