 class UserAccount: NSObject, NSCoding {
 
     var access_token: String?
-    var expires_in: Int = 0
+    // 从授权开始 多少秒之后过期时间
+    var expires_in: Int = 0 {
+        didSet {
+            expires_Date = NSDate(timeIntervalSinceNow: NSTimeInterval(expires_in))
+        }
+    }
+    // 真正过期时间
+    var expires_Date: NSDate?
     var uid: String?
     
     init(dict: [String: AnyObject]) {

    class func loadUserAccount() -> UserAccount? {
        
        if UserAccount.account != nil {
            return UserAccount.account
        }
        
        guard let account = NSKeyedUnarchiver.unarchiveObjectWithFile(UserAccount.filePath) as? UserAccount else {
            return UserAccount.account
        }
        UserAccount.account = account
        
        return UserAccount.account

        aCoder.encodeObject(access_token, forKey: "access_token")
        aCoder.encodeInteger(expires_in, forKey: "expires_in")
        aCoder.encodeObject(uid, forKey: "uid")
        aCoder.encodeObject(expires_Date, forKey: "expires_Date")
    }
    
    required init?(coder aDecoder: NSCoder) {
        self.access_token = aDecoder.decodeObjectForKey("access_token") as? String
        self.expires_in = aDecoder.decodeIntegerForKey("expires_in") as Int
        self.uid = aDecoder.decodeObjectForKey("uid") as? String
        self.expires_Date = aDecoder.decodeObjectForKey("expires_Date") as? NSDate
    }

}
