我在尝试访问该属性时,我的Realm对象返回0时遇到一些问题。
当我这样做时:
print(calculation)
print(calculation.homePrice)
它给了我:
PaymentsCalculation {
id = 90941762-E648-4377-ABA3-4BDA88880768;
homePrice = 200000;
downPayment = 40000;
interestRate = 0.04;
homeInsurance = 900;
HOADues = 0;
loanType = 30-year fixed;
hidePMI = 0;
}
0.0
为什么会这样?
计算是来自User
class:
import RealmSwift
class User: Object {
var id: String = NSUUID().UUIDString
let monthlyPayments = List<PaymentsCalculation>()
override static func primaryKey() -> String? {
return "id"
}
}
答案 0 :(得分:3)
卫生署。
在dynamic
homePrice
如果有人遇到同样的问题:
请记住这样做:
dynamic var homePrice: Double = 0.0