我对Realm
. 当我第一次从 Realm 数据库中获取对象并从数据库中删除对象时。展开可选值nil
。
模型:
class Outlet: Object {
@objc dynamic var id:string = ""
@objc dynamic var name:string = ""
@objc dynamic var name1:Double = 0.0
@objc dynamic var name2:Double = 0.0
@objc dynamic var name3:Double = 0.0
@objc dynamic var name4:Double = 0.0
@objc dynamic var name5:Int = 0
let OutletListS = List<OutletList>()
override class func primaryKey() -> String? {
return "id"
}
}
班级:
class DBManager {
private var database: Realm
static let sharedInstance = DBManager()
private init() {
database = try! Realm()
}
func getDataFromDB() -> Outlet {
let result = database.objects(Outlet.self)
return result.first!
}
}
和调用方法:
let selectedOutlet = DBManager.sharedInstance.getDataFromDB()
错误:
Printing description of result:
Results <0x7fb64f02c230> (
)
我自己无法解决。请帮帮我。