Created
December 3, 2017 12:35
-
-
Save azamsharp/45d8d035e1f2be0a4ee9eeed00f8fd21 to your computer and use it in GitHub Desktop.
User NSCoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class User : NSObject, NSCoding { | |
var username :String! | |
var password :String! | |
var userId :String! | |
init(username :String, password :String) { | |
self.username = username | |
self.password = password | |
} | |
public func encode(with aCoder: NSCoder) { | |
aCoder.encode(self.userId,forKey: "userId") | |
aCoder.encode(self.username, forKey: "username") | |
aCoder.encode(self.password, forKey: "password") | |
} | |
public required init?(coder aDecoder: NSCoder) { | |
self.userId = aDecoder.decodeObject(forKey: "userId") as! String | |
self.username = aDecoder.decodeObject(forKey: "username") as! String | |
self.password = aDecoder.decodeObject(forKey: "password") as! String | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment