Skip to content

Instantly share code, notes, and snippets.

@vikitripathi
Forked from pgpt10/Codable6.swift
Created November 6, 2017 11:56
Show Gist options
  • Save vikitripathi/f949ecb4fa03388524fb06f08528eb89 to your computer and use it in GitHub Desktop.
Save vikitripathi/f949ecb4fa03388524fb06f08528eb89 to your computer and use it in GitHub Desktop.
class City: NSObject, NSCoding
{
var name: String?
var id: Int?
required init?(coder aDecoder: NSCoder)
{
self.name = aDecoder.decodeObject(forKey: "name") as? String
self.id = aDecoder.decodeObject(forKey: "id") as? Int
}
func encode(with aCoder: NSCoder)
{
aCoder.encode(self.name, forKey: "name")
aCoder.encode(self.id, forKey: "id")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment