[翻译] SSKeychain
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:
或者手动添加到项目当中:
- Add
Security.frameworkto your target 添加Security.framework框架 - Add
SSKeychain.h,SSKeychain.m,SSKeychainQuery.h, andSSKeychainQuery.mto your project. 将SSKeychain.h,SSKeychain.m,SSKeychainQuery.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的更多相关文章
- 《Django By Example》第五章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者@ucag注:大家好,我是新来的翻译, ...
- 《Django By Example》第四章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:祝大家新年快乐,这次带来<D ...
- [翻译]开发文档:android Bitmap的高效使用
内容概述 本文内容来自开发文档"Traning > Displaying Bitmaps Efficiently",包括大尺寸Bitmap的高效加载,图片的异步加载和数据缓存 ...
- 【探索】机器指令翻译成 JavaScript
前言 前些时候研究脚本混淆时,打算先学一些「程序流程」相关的概念.为了不因太枯燥而放弃,决定想一个有趣的案例,可以边探索边学. 于是想了一个话题:尝试将机器指令 1:1 翻译 成 JavaScript ...
- 《Django By Example》第三章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:第三章滚烫出炉,大家请不要吐槽文中 ...
- 《Django By Example》第二章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:翻译完第一章后,发现翻译第二章的速 ...
- 《Django By Example》第一章 中文 翻译 (个人学习,渣翻)
书籍出处:https://www.packtpub.com/web-development/django-example 原作者:Antonio Melé (译者注:本人目前在杭州某家互联网公司工作, ...
- 【翻译】Awesome R资源大全中文版来了,全球最火的R工具包一网打尽,超过300+工具,还在等什么?
0.前言 虽然很早就知道R被微软收购,也很早知道R在统计分析处理方面很强大,开始一直没有行动过...直到 直到12月初在微软技术大会,看到我软的工程师演示R的使用,我就震惊了,然后最近在网上到处了解和 ...
- ASP.NET MVC with Entity Framework and CSS一书翻译系列文章之第一章:创建基本的MVC Web站点
在这一章中,我们将学习如何使用基架快速搭建和运行一个简单的Microsoft ASP.NET MVC Web站点.在我们马上投入学习和编码之前,我们首先了解一些有关ASP.NET MVC和Entity ...
随机推荐
- WPF为ItemsControl设置ItemsPanelTemplate
1. 直接在XAML中以对象属性的方式 <ItemsControl x:Name="lstNew"> <ItemsControl.ItemsPanel> & ...
- Linux下MyCat和MyCat_web的安装和配置
Linux下MyCat和MyCat_web的安装和配置 Mycat 是一个数据库分库分表中间件 Mycat web 可以对 Mycat进行监控,这里分享一下 Mycat web 的搭建过程 详细内容可 ...
- Java的Date类与Calendar
一.Date类 在JDK1.0中,Date类是唯一的一个代表时间的类,但是由于Date类不便于实现国际化,所以从JDK1.1版本开始,推荐使用Calendar类进行时间和日期处理.这里简单介绍一下Da ...
- haproxy配置文件详解--转
原始出处:http://itnihao.blog.51cto.com/1741976/915537 #/usr/local/sbin/haproxy -f /etc/haproxy/haproxy.c ...
- eclipse + maven 环境配置
软件152 余建强 第一步:准备以下软件并进行安装 1. jdk1.7或者以上为最佳: 官方下载地址:http://www.oracle.com/technetwork/java/javase/dow ...
- Node.js之Express四
Express提供的大部分功能是通过中间件函数完成的,这些中间件函数在Node.js收到请求的时点和发送响应的时点之间执行.Express的Connect模块提供了中间件框架,可以方便的在全局或路径级 ...
- 页面刷新 location.reload()
* 页面不刷新,但是加了location.reload()后,把炒作失败提示语都刷没了.//成功,不提示,刷新看数据变化ajax success:function(res){ if(res.code= ...
- swagger 集成asp.net Core2.1
首先通过nuget 安装 Swashbuckle.AspNetCore 1.在startup.cs 的configureService services.AddAutoMapper(); serv ...
- dynamic结合匿名类型 匿名对象传参
首先说明下,我一般很少用dynamic关键字(类)的,因为毕竟是由反射实现的,所以对于性能方面还是吃亏不少(注:由于心里没底,查了一些资料得知,dynamic实质上好像不是由反射实现的,其性能也比直接 ...
- 安装SQL SEVER 2017 express 轻量入门级软件 安装教程
1. 首先 打开网址 https://www.microsoft.com/zh-tw/sql-server/sql-server-downloads 点击下载 , 下载完成之后, 点开安装 ...