Skip to content

Instantly share code, notes, and snippets.

@axiixc
Created June 23, 2014 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axiixc/d0aa5dd798fd926143be to your computer and use it in GitHub Desktop.
Save axiixc/d0aa5dd798fd926143be to your computer and use it in GitHub Desktop.
// class CountDownEvent {
// init(endDate: NSDate, name: String);
// }
extension CountDownEvent: NSSecureCoding {
convenience init(coder: NSCoder!) {
let endDate = coder.decodeObjectOfClass(NSDate.classForCoder(), forKey: "endDate") as NSDate
let name = coder.decodeObjectOfClass(NSString.classForCoder(), forKey: "name") as NSString
self.init(endDate: endDate, name: name) // Is this not how you call another initializer?
}
func encodeWithCoder(coder: NSCoder!) -> Void {
coder.encodeObject(endDate, forKey: "endDate")
coder.encodeObject(name, forKey: "name")
}
class func supportsSecureCoding() -> Bool {
return true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment