 import Foundation
 
 // Data model for an item that belongs to a list.
-class ListItem : NSObject {
+class ListItem : NSObject, NSCoding {
     // A unique ID
     let identifier: String
     

        self.title = title
        self.items = []
    }
}
        self.identifier = NSUUID.init().UUIDString
        self.title = title
    }
    
    // MARK: NSCoding
    
    required init?(coder aDecoder: NSCoder) {
        if let identifier = aDecoder.decodeObjectForKey("identifier") as? String {
            self.identifier = identifier
        } else {
            self.identifier = NSUUID.init().UUIDString
        }
        
        if let title = aDecoder.decodeObjectForKey("title") as? String {
            self.title = title
        }
        
        if let completed = aDecoder.decodeObjectForKey("completed") as? NSNumber {
            self.completed = completed.boolValue
        }
    }
    
    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(self.identifier, forKey: "identifier")
        aCoder.encodeObject(self.title, forKey: "title")
        aCoder.encodeBool(self.completed, forKey: "completed")
    }
}

// Data model for a list
class List : NSObject, NSCoding {
    // A unique ID
    let identifier: String
    
