I need to save my array to Core Data.
let array = [8, 17.7, 18, 21, 0, 0, 34]
The values inside that array, and the number of values are variable.
1. What do I declare inside my NSManagedObject class?
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. What do I declare inside my .xcdatamodel?
3. How do I save this in my Entity? (I use MagicalRecord)
let statistics = (PBOStatistics.MR_createInContext(context) as! PBOStatistics)
statistics.values = [8, 17.7, 18, 21, 0, 0, 34] //is it enough?
NSManagedObject
:@NSManaged var values: [Double]
is it good? Can you tell me what type should I use in.xcdatamodel
to save this? – Baalbeer