Core Data NSTimeInterval using an accessor directly is buggy

后端 未结 2 1964
借酒劲吻你
借酒劲吻你 2020-12-19 15:36

I\'m setting an NSTimeInterval using setValueForKey within an NSManagedObject Subclass, the value gets set correctly, and is also correct when it is retrieved using valueFor

2条回答
  •  Happy的楠姐
    2020-12-19 16:04

    Assigning to self.valueForKey("dateLastSynced") won't work; it's not an lvalue. You need to use setValueForKey.

    Also, if the dateLastSynced is a date property, you cannot assign it a double value and expect it to work. Use

    self.setValue(NSDate(timeIntervalSinceReferenceDate: ), forKey:"dateLastSynced")
    

提交回复
热议问题