I'm new to Core Data but for a new project of mine, I would like to save my data to Core Data. I want to create a Reptile-class which contains a couple of custom class arrays. Without Core Data I would have something like this:
import Foundation
import UIKit
class Reptile_ {
private var _name: String?
private var _dateOfBirth: String?
private var _morph: String?
private var _breed: String?
private var _feedingPeriodInDays: Int?
private var _reminderTime: NSDate?
private var _idealTemperatureAtDay: String?
private var _idealTemperatureAtNight: String?
private var _gender: Gender?
private var _image: UIImage?
private var _imageHeader: UIImage?
private var _sheddings: [Shedding_]?
private var _feedings: [Feeding_]?
private var _defecations: [Defecation_]?
private var _weights: [Weight_]?
private var _lengths: [Length_]?
private var _others: [Others_]?
}
And e.g. the class Weight_
would look something like this:
import Foundation
class Weight_ {
private var _date: NSDate?
private var _weight: Double?
}
I can use Core Data to save a single class with some attributes as Strings, Boolean Data, ... But I do not know how I would save the arrays of custom objects?
I've read somewhere that I need to create Relationships (one to many) with the base Reptile
class. So I've done that which resulted in this:
Is this the correct way for adding an array of custom objects? If so, How do I continue (simply click 'CreateNSManagedObject Subclass...'?)? How do I add a instance to the array? How do I read it?