SSKeychain 这个库是对iOS安全框架的封装,使用起来极其简单。
git:https://github.com/samsoffes/sskeychain
这里贴下使用代码:
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [SSKeychain setPassword:@"123" forService:@"com.service.service" account:@"account"]; NSString *password = [SSKeychain passwordForService:@"com.service.service" account:@"account"]; NSLog(@"password = %@",password); // Getting Accounts NSArray *accounts = [SSKeychain allAccounts]; NSLog(@"accounts = %@",accounts); accounts = [SSKeychain accountsForService:@"com.service.service"]; NSLog(@"accounts = %@",accounts); // Deleting Passwords [SSKeychain deletePasswordForService:@"com.service.service" account:@"account"]; password = [SSKeychain passwordForService:@"com.service.service" account:@"account"]; NSLog(@"password = %@",password); }
代码下载:http://download.csdn.net/detail/qqmcy/8520719
时间: 2024-10-23 18:54:11