خرید بک لینک

Vote count: 0

I have a simple class

class FarmRecord: Object {
    dynamic var year = ""
    dynamic var month = ""
    dynamic var day = ""

    func setYearID(inYear: String) {
        self.year = inYear
        compoundKey = compoundKeyValue()
    }
    func setMonthID(inMonth: String) {
        self.month = inMonth
        compoundKey = compoundKeyValue()
    }
    func setDayID(inDay: String) {
        self.day = inDay
        compoundKey = compoundKeyValue()
    }


    dynamic lazy var compoundKey: String = self.compoundKeyValue()

    private func compoundKeyValue() -> String {
        retu "(year)(month)(day)"
    }

    override static func primaryKey() -> String? {
        retu "compoundKey"
    }
}

I tried to add object as follow:

let storeRealm = try! Realm()
let farm = FarmRecord()
farm.setYearID("2016")
farm.setMonthID("3")
  farm.setDayID("1")
    do {
        try storeRealm.write({ () -> Void in
            storeRealm.add(farm)
            })
    } catch {

    }

And I got EXEC_BAD_ACCESS (code = 1), error I even tried storeRealm.add(farm, update: true) with no difference

I should work but it didn't. Please help

asked 56 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 26 اسفند 1394 ساعت: 6:48

صفحه بندی