我是一個新的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