I am having some trouble using JSONModel in Swift.
I am trying to create a ToDo list app that would persist a collection of items so that the ToDo items are preserved when the app is closed. This is the code I use:
class ToDoItem: JSONModel {
var name: String = ""
var isCompleted: Bool = false
var createdOn: NSDate = NSDate()
}
class ToDoList: JSONModel {
var items: [ToDoItem] = []
}
I can convert a ToDoItem
to JSON by calling toJSONString()
but the same method doesn't work with ToDoList
, it returns nil. Any idea why is this happening?