I am trying to learn Swift and having difficulties storing an array of my custom class. Here are my classes
import Foundation
class Entry {
var company: String
var category: String
var amount: Double
var type: String
init() {
self.company = ""
self.category= ""
self.amount= ""
self.type= ""
}
}
I have another class that is an array of entries called a checkbook
import Foundation
class Checkbook {
var entries = [Entry]()
init() {
self.entries = []
}
}
Then in my view controller I have an array of checkbooks. I need to store that array of checkbooks so it keeps all its data next time the app opens up. What is the best way to do this?
NSUserdefaults. If you have a lot of data, then you can start looking into mobile databases like core data or realm.