我是一个新的Xcode开发,我需要一些帮助与境界数据库 。这些都是我的表Realm.objects(类型)返回空的对象
class Parent: Object {
var id :Int = 0
var name: String = ""
}
class Surah: Parent {
dynamic var ayatNum = 0
private var fav : Bool {
set { self.fav = newValue }
get { return self.fav }
}
init(id: Int , ayat: Int , name: String) {
super.init()
super.id = id
self.ayatNum = ayat
super.name = name
}
override static func primaryKey() -> String? {
return "id"
}
required init(realm: RLMRealm, schema: RLMObjectSchema) {
super.init()
}
required init(value: AnyObject, schema: RLMSchema) {
super.init()
}
required init() {
super.init()
}
}
class Reader: Parent{
private var fav: Bool {
set { self.fav = newValue }
get { return self.fav }
}
init(id: Int , name: String) {
super.init()
self.id = id
self.name = name
}
override static func primaryKey() -> String? {
return "id"
}
required init(realm: RLMRealm, schema: RLMObjectSchema) {
super.init()
}
required init(value: AnyObject, schema: RLMSchema) {
super.init()
}
required init() {
super.init()
}
}
,当我把这些线和存储结果在一个数组,并打印
realm = try!Realm()
readers = Array(realm.objects(Reader.self))
print(readers)
,我尝试这一个也
readers = Array(try!Realm().objects(Reader.self))
print(readers)
它打印S上的空对象
Reader {
id = 0;
name = ;
}, Reader {
id = 0;
name = ;
}, Reader {
id = 0;
name = ;
}
我搜索一下这个问题在计算器,找到解决方案,它并没有解决我的问题
Realm.objects() returns empty objects
任何一个可以帮助我!
thaaanks alot super – Inspiration