Latest 1.0.3
Homepage https://github.com/YuriFox/YFKeychainAccess
License MIT
Platforms ios 8.0
Authors

[platform]()
[language]()
[language]()
[license]()

Convenient, beautiful and easy to use KeychainAccess, that written in Swift

Requirements

  • iOS 8.0+
  • Xcode 9.0+
  • Swift 4.0+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods
  • Create Podfile into your Xcode project. Open up Terminalcd into your project’s top-level directory → Run the following command:
$ pod init
  • Open up created Podfile.
$ open Podfile
  • In the Podfile that appears, specify. Instead of <Your Target Name>, enter your project’s name :
platform :ios, ‘8.0’

target '<Your Target Name>' do
    use_frameworks!
    pod 'YFKeychainAccess'
end
  • Then, run the following command:
$ pod update
$ pod install
  • Finally, open your Xcode <Your Target Name>.xcworkspace.

Usage

import YFKeychainAccess

Set

let keychain = YFKeychainAccess() // You can add 'keyPrefix' and 'options' to customize KeychainAccess

do {
    try keychain.set(value, forKey: "KEY") // You can add 'accessible' parameter too
    // 'set' function update item or creates a new one
} catch {
    // Handle error if necessary
}

Get

let keychain = YFKeychainAccess() // You can add 'keyPrefix' and 'options' to customize KeychainAccess

do {
    let data = try keychain.data(forKey: "DATA_KEY")
    let string = try keychain.string(forKey: "STRING_KEY")
    let bool = try keychain.bool(forKey: "BOOL_KEY")
    let int = try keychain.(forKey: "INT_KEY")
    let float = try keychain.float(forKey: "FLOAT_KEY")
    let double = try keychain.double(forKey: "DOUBLE_KEY")
} catch {
    // Handle error if necessary
}

Delete

let keychain = YFKeychainAccess() // You can add 'keyPrefix' and 'options' to customize KeychainAccess

do {
    try keychin.delete(forKey: "KEY") // Delete one item for key
    try keychin.deleteAll() // Delete all item for this app
} catch {
    // Handle error if necessary
}

Contains

let keychain = YFKeychainAccess() // You can add 'keyPrefix' and 'options' to customize KeychainAccess

do {
    try keychin.contains(forKey: "KEY")
} catch {
    // Handle error if necessary
}

License

Released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "YFKeychainAccess",
    "version": "1.0.3",
    "summary": "Convenient, beautiful and easy to use KeychainAccess, that written in Swift",
    "homepage": "https://github.com/YuriFox/YFKeychainAccess",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "YuriFox": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/YuriFox/YFKeychainAccess.git",
        "tag": "1.0.3"
    },
    "source_files": "Source/*.swift",
    "pushed_with_swift_version": "4.0"
}

Pin It on Pinterest

Share This