Hey All,
I will try over here and see if you all have any ideas.
I have an app in the app store that I am waiting to submit until I figure how to protect the user’s data they have already placed in the database
Here is the current Model:
Here are my models The first is the original:
class Registry: Object {
//Date, time, place and type
@objc dynamic var registryId = UUID().uuidString
@objc dynamic var dateTime:String?
@objc dynamic var proper:String?
@objc dynamic var service:String?
@objc dynamic var place:String?
//Attendance
//Sunday
@objc dynamic var sunEuchAttendance:Int = 0
//All Other services
@objc dynamic var otherServiceAttendance:Int = 0
@objc dynamic var EuchVisitor:Int = 0
//Commuion
@objc dynamic var numberOfCommunions:Int = 0
//People serving
@objc dynamic var presiderOfficiant:String?
@objc dynamic var preacher:String?
@objc dynamic var server:String?
@objc dynamic var memo:String?
//Stats
//Eucharist
@objc dynamic var weekendEuch:Int = 0
@objc dynamic var weekdayEuch:Int = 0
@objc dynamic var privateEuch:Int = 0
//Office
@objc dynamic var weekendOffice:Int = 0
@objc dynamic var weekdayOffice:Int = 0
//Other services
@objc dynamic var burrial:Int = 0
@objc dynamic var marraige:Int = 0
//Other services and memos
@objc dynamic var other:Int = 0
override static func primaryKey() -> String? {
return “registryId”
}
override static func indexedProperties() -> [String] {
return [“service”]
}
}
And when I update the app to include lists I need to migrate exiesting data into the new list:
class AllServices: Object {
var everything = List()
var eucharist = List()
var weekdayEucharist = List()
var office = List()
var weekdayOffice = List()
var marriage = List()
var burial = List()
var requiem = List()
var nuptial = List()
var other = List()
}
I was told to do this:
Here is how you should do:
1.) create a new list, with the type of property “var newList = List()”
2.) iterate over all of the old data and create a Registry from each of them “let newData = Registry.init(…)”
3.) add those data to the newList “newList.add(newData)”
4.) set the newData new property to the newList “newObject[“listProperty”] = newList”
But for the life of me, I can’t figure out how to execute the instructions. When I try them, I get s serries of errors.
Thanks so much for the help!
Blessings,
—Mark