KeychainStorage 1.3.0

KeychainStorage 1.3.0

Radu Dan 维护。



  • Radu Dan

Keychain Storage

build Carthage Carthage iOS Twitter: @radude89

Keychain Storage 是一个用 Swift 编写的简单的 Keychain 封装。
如果您希望在不写太多代码的情况下在 Keychain 中保存某些内容,您就来到了正确的地方。

要求

  • iOS 12.0+
  • Xcode 10.2+
  • Swift 5+

安装

Cocoa Pods

Cocoa Pods 是 Cocoa 项目的依赖管理器。有关使用和安装说明,请访问他们的网站。使用 CocoaPods 将 Keychain Storage 集成到您的 Xcode 项目中,请在您的 Podfile 中指定它。

pod 'KeychainStorage', '~> 1.3'

Carthage

Carthage 是一个分布式的依赖管理器,它构建您的依赖并提供二进制框架。要使用 Carthage 将 KeychainStorage 集成到您的 Xcode 项目中,请在您的 Cartfile 中指定它。

github "radude89/KeychainStorage" "1.3"

手册

将以下在 KeychainStorage 中找到的项目拖放到您的项目中。

  • KeychainQueryFactory.swift
  • KeychainStorage.swift
  • KeyValueStorage.swift

示例

请确保尝试运行示例小应用程序,位于: Example/KeychainStorageExample.xcworkspace
构建 & 运行。

在 Keychain 中保存值

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.set("secret", key: "myStringKey")

try? storage.set(true, key: "myBoolKey")

从 Keychain 中检索值

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")

if let myStringValue = try? storage.string(forKey: "myStringKey") {
    // do something with myStringValue
}

if let myBoolValue = try? storage.bool(forKey: "myBoolKey") {
    // do something with myBoolValue
}

从 Keychain 中删除值

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.removeValue(forKey: "myStringKey")

从 Keychain 中删除所有值

import KeychainStorage

let storage = KeychainStorage(service: "com.test.service")
try? storage.removeAll()

许可

KeychainStorage 在 MIT 许可下发布。请参阅 LICENSE 文件以获取详细信息。

贡献 & 支持

KeychainStorage是一个开源项目。我鼓励每个人贡献。

如果有建议或改进想法,请提交拉取请求。

谢谢!