import UIKit
struct Task {
    var name: String
    var completed: Bool
}
class ListModel {
    var tasks: [Task] = [] // array to store tasks of todo list
    let defaluts = UserDefaults.standard
    func addTask( name: String, completed: Bool ) {   // store task with status of complete into array
        self.tasks.append( Task( name: name, completed: completed ) )
    }
    var tasksValue: [Task] { // getter and setter of array tasks
        get {
            return tasks
        }
        set {
            tasks = newValue
        }
    }
    func save() {
        defaluts.set(tasks, forKey: "tasks")
    }
    func load() {
        if let value = defaluts.array(forKey: "tasks") as? [Task] {
            tasks = value 
        }
    }
}
When I run my program, it displays error that Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to insert non-property list object. 
Can someone help me fix it please?
 
    