如果我只想在 Realm 中存储字符串数组,是否必须将其包装在扩展 Object
的自定义类中?
示例:
class ExampleObject : Object {
var stringArray : List<String>
}
最佳答案
从 Realm-Cocoa 3.0.0 开始就没有了。
Loosen RLMArray and RLMResults's generic constraint from RLMObject to NSObject. This may result in having to add some casts to disambiguate types.
和
List can now contain values of types Bool, Int, Int8, Int16, Int32, Int64, Float, Double, String, Data, and Date (and optional versions of all of these) in addition to Object subclasses.
Querying Lists containing values other than Object subclasses is not yet implemented.
所以以下应该可以正常工作:
class Student : Object {
let stringArray = List<String>()
}
关于swift - 在 Realm 中存储字符串数组列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51430521/