IOS keyChain (simple use of key string), ioskeychain

Source: Internet
Author: User
Tags key string

IOS keyChain (simple use of key string), ioskeychain

In development, we usually need to save some values for a long time, such as the user's account and password. It is especially important to ensure data security for data with high privacy. KeyChain in ios is a good choice.

First, go to the developer website (https://developer.apple.com/library/ios/navigation/) to download a sample project called GenericKeychain.

We only need

Copy "KeychainItemWrapper. h" and "KeychainItemWrapper. m" to our project and import Security. framework

You also need to disable ARC for this class:

Buliding phase find the corresponding file-fno-objc-arc

The basic usage code is as follows:

KeychainItemWrapper * wra; @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad]; wra = [[KeychainItemWrapper alloc] handler: @ "password" accessGroup: @ "wjl.com"]; -(IBAction) getOb :( id) sender {/***** @ param @ "account % @" * @ param id must be Security. secitem. */NSLog (@ "account =%@", [wra objectForKey :( id) kSecAttrAccount]);}-(IBAction) clear :( id) defined in h) sender {[wra resetKeychainItem]; // clear settings}-(IBAction) set :( id) sender {[wra setObject: @ "wjl123" forKey :( id) kSecAttrAccount];}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.