账号管理 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://www.codercto.com/soft/d/10516.html

Algorithms + Data Structures = Programs

Algorithms + Data Structures = Programs

Niklaus Wirth / Prentice Hall / 1975-11-11 / GBP 84.95

It might seem completely dated with all its examples written in the now outmoded Pascal programming language (well, unless you are one of those Delphi zealot trying to resist to the Java/.NET dominanc......一起来看看 《Algorithms + Data Structures = Programs》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具