我需要将阵列保存到Core Data。
let array = [8, 17.7, 18, 21, 0, 0, 34]
该数组中的值以及值的数量是可变的。
1.我在NSManagedObject类中声明什么?
class PBOStatistics: NSManagedObject, Equatable {
@NSManaged var date: NSDate
@NSManaged var average: NSNumber
@NSManaged var historicAverage: NSNumber
@NSManaged var total: NSNumber
@NSManaged var historicTotal: NSNumber
@NSManaged var ordersCount: NSNumber
@NSManaged var historicOrdersCount: NSNumber
@NSManaged var values: [Double] //is it ok?
@NSManaged var location: PBOLocation
}
2.我在.xcdatamodel中声明什么?
3.如何将其保存在我的实体中?(我使用MagicalRecord)
let statistics = (PBOStatistics.MR_createInContext(context) as! PBOStatistics)
statistics.values = [8, 17.7, 18, 21, 0, 0, 34] //is it enough?