SSKeychain

https://github.com/soffes/sskeychain

SSKeychain is a simple wrapper for accessing accounts, getting passwords, setting passwords, and deleting passwords using the system Keychain on Mac OS X and iOS.

SSKeychain是一个对keychain简易封装的开源库,用以存储用户信息,密码信息等.

Adding to Your Project

Simply add the following to your Podfile if you're using CocoaPods:

你可以用CocoaPods安装,在Podfile中写入下面一句话:

pod 'SSKeychain'

or Cartfile if you're using Carthage:

如果你是在使用Carthage,写入下面一句话:

github "soffes/SSKeychain"

To manually add to your project:

或者手动添加到项目当中:

  1. Add Security.framework to your target 添加Security.framework框架
  2. Add SSKeychain.hSSKeychain.mSSKeychainQuery.h, and SSKeychainQuery.m to your project. 将SSKeychain.hSSKeychain.mSSKeychainQuery.h, 与 SSKeychainQuery.m添加到你的项目当中.

SSKeychain requires ARC.

SSKeychain需要开启ARC.

Note: Currently SSKeychain does not support Mac OS 10.6.

注意:当前的SSKeychain并不支持Mac OS 10.6

Working with the Keychain

SSKeychain has the following class methods for working with the system keychain:

SSKeychain有以下的一些方法供你使用:

+ (NSArray *)allAccounts;
+ (NSArray *)accountsForService:(NSString *)serviceName;
+ (NSString *)passwordForService:(NSString *)serviceName account:(NSString *)account;
+ (BOOL)deletePasswordForService:(NSString *)serviceName account:(NSString *)account;
+ (BOOL)setPassword:(NSString *)password forService:(NSString *)serviceName account:(NSString *)account;

Easy as that. (See SSKeychain.h and SSKeychainQuery.h for all of the methods.)

是不是很简单.(你可以在 SSKeychain.h 与 SSKeychainQuery.h 中看到所有相关方法)

Documentation

Read the online documentation.

你可以阅读在线文档.

Debugging

If your saving to the keychain fails, use the NSError object to handle it. You can invoke [error code]to get the numeric error code. A few values are defined in SSKeychain.h, and the rest in SecBase.h.

如果你存储keychain操作失败,请使用NSError来捕获他.

NSError *error = nil;
SSKeychainQuery *query = [[SSKeychainQuery alloc] init];
query.service = @"MyService";
query.account = @"soffes";
[query fetch:&error]; if ([error code] == errSecItemNotFound) {
NSLog(@"Password not found");
} else if (error != nil) {
NSLog(@"Some other error occurred: %@", [error localizedDescription]);
}

Obviously, you should do something more sophisticated. You can just call [error localizedDescription] if all you need is the error message.

Disclaimer

Working with the keychain is pretty sucky. You should really check for errors and failures. This library doesn't make it any more stable, it just wraps up all of the annoying C APIs.

Thanks

This was originally inspired by EMKeychain and SDKeychain (both of which are now gone). Thanks to the authors. SSKeychain has since switched to a simpler implementation that was abstracted fromSSToolkit.

A huge thanks to Caleb Davenport for leading the way on version 1.0 of SSKeychain.

[翻译] SSKeychain的更多相关文章

  1. 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...

  2. 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...

  3. [翻译]开发文档:android Bitmap的高效使用

    内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...

  4. 【探索】机器指令翻译成 JavaScript

    前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...

  5. 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...

  6. 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...

  7. 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)

    书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...

  8. 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?

    0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...

  9. ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点

    在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...

随机推荐

  1. xgb 绘制

    1.windows安装Graphviz2.38 安装地址:https://graphviz.gitlab.io/_pages/Download/Download_windows.html 2.在pyt ...

  2. 终极 shell zsh

    在mac上安装zsh,推荐安装. 参见http://macshuo.com/?p=676. 安装成功提示,看着很帅的样子

  3. ASP.NET Core 中的对象映射之 AutoMapper

    目录 AutoMapper 简介 AutoMapper 使用 初始化 Profile设置 扁平化映射 集合映射 投影 条件映射 值转换 设置转换前后行为 配置验证及设置 反向映射 自定义转换器 自定义 ...

  4. JS的可枚举性

        在学习ES6的过程中,涉及到遍历方法时,提到过可枚举性,且多种遍历方法都与可枚举性相关.本章节,将总结这些遍历方法的可枚举性,并在必要的部分,给出对比实例. 一.设置属性的可枚举性 在上一文章 ...

  5. 前端神器之Sublime Text2/3简单明了使用总结

    为什么叫神器呢? 我总结如下: 第一:也是最重要的,它占内存很小(就如同notepad++那般迅速打开,所以那款其实也不错~).一般IDE比如WebStorm(它也是一款神器来着),Aptana(也比 ...

  6. kubernetes continually evict pod when node's inode exhausted

    kubernetes等容器技术可以将所有的业务进程运行在公共的资源池中,提高资源利用率,节约成本,但是为避免不同进程之间相互干扰,对底层docker, kubernetes的隔离性就有了更高的要求,k ...

  7. 不用bootstrap,只用CSS创建网格布局

    本文译自[http://j4n.co/blog/Creating-your-own-css-grid-system],英语好的,可直接查看原网页,不需要FQ. 翻译拿不准的地方会有英文原文,方便大家理 ...

  8. ARP协议抓包之帧长度和Gratuitous ARP的问题

    用Winpcap编程构造ARP包选择网卡并发出,遇到若干问题,学到了许多新知识,但是有的还尚未解决,在这里记录下没解决的和解决的问题. 先来看下ARP协议的格式,ARP字段有28个字节,发到以太网中还 ...

  9. T-sql 编程

    ---------------------------T-SQL编程--------------------------1.声明变量--declare @name nvarchar(50)--decl ...

  10. SpringMVC中properties文件读取

    SpringMVC给我们提供了用于properties文件读取的类: org.springframework.context.support.ResourceBundleMessageSource 1 ...