账号管理 WAAccountStore

码农软件 · 软件分类 · 其他(Others) · 2019-07-20 05:57:46

软件介绍

WAAccountStore 是一个简单并且可扩展的账号系统。它封装了基本的账号管理函数,帐户凭据的安全存储,允许你存储任何关于账号的有用信息。

使用示例:

使用你 App 的默认存储

WAAccountStore.defaultStore()

或许你想直接使用 WAAccountStore 。不过,WAAccountCredentialWAAccount 创建一些简单的扩展可以让你的工作更轻松。

例如:

将你的用户模块和 WAAccount 联结

//Assuming `User` is your user model class.
extension WAAccount {
    var user: User {
        get {
            return self.userInfo as! User
        }
    }
    convenience init(identifier: String, credential: WAAccountCredential, user: User) {
        self.init(identifier: identifier, credential: credential, userInfo: user)
    }
}

直接进入 WAAccountCredential 的 securityStorage 不太方便,所以先创建一个方便进入的扩展。

let UserAccessTokenStorageKey = "AccessToken"
extension WAAccountCredential {
    var accessToken: String {
        get {
            return self.securityStorage[UserAccessTokenStorageKey] as! String
        }
    }
    convenience init(identifier: String, accessToken: String) {
        self.init(identifier: identifier, securityStorage: [UserAccessTokenStorageKey: accessToken])
    }
}


本文地址:https://codercto.com/soft/d/10516.html

The Art and Science of CSS

The Art and Science of CSS

Jonathan Snooks、Steve Smith、Jina Bolton、Cameron Adams、David Johnson / SitePoint / March 9, 2007 / $39.95

Want to take your CSS designs to the next level? will show you how to create dozens of CSS-based Website components. You'll discover how to: # Format calendars, menus and table of contents usin......一起来看看 《The Art and Science of CSS》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

随机密码生成器
随机密码生成器

多种字符组合密码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具