User remembers account, password in IOS development

Source: Internet
Author: User

Remembering accounts and passwords is often used in iOS development to improve the user experience. The following is a brief account, password storage.

First, Login

Log the logged-in user step and store it into an array in preferences.

Specific storage

1: Store users into preferences, where the user is an array of actions after responding to the client to the server (if the response data succeeds) where the user and password are one by one corresponding

 1.1 First read the corresponding user collection from the Sandbox preferences read user name: Nsmutablearray *accarys = [Nsmutablearray arraywitharray:[[nsuserdefaults Standarduserdefaults] VALUEFORKEY:USERS_SWGLM]; Read password: Nsmutablearray *pwdarys = [Nsmutablearray arrayWithArray:[[ Nsuserdefaults Standarduserdefaults] valueforkey:users_pwd];   1.2 Deviate array and user input user name, compare, if different, join enter. 1. 3 Storing the user name in the sandbox ([[Nsuserdefaults standarduserdefaults] Setvalue:accarys FORKEY:USERS_SWGLM]; store password [[  Nsuserdefaults Standarduserdefaults] Setvalue:accarys forkey:users_pwd]; 1.4 Last call to synchronize data [[nsuserdefaults standarduserdefaults]synchronize]; 2: Delete drop-down user, 1.1 first read user name from the corresponding user set in sandbox preferences: Nsmuta Blearray *accarys = [Nsmutablearray arraywitharray:[[nsuserdefaults standarduserdefaults] ValueForKey:USERS_SWGLM]]; Read password: Nsmutablearray *pwdarys = [Nsmutablearray arraywitharray:[[nsuserdefaults standarduserdefaults] ValueForKey:   USERS_PWD]]; 1.2: Iterate through the array, exclude the deleted user to get the remaining array, store the user name in sync [[[Nsuserdefaults Standarduserdefaults] Setvalue:accarys FORKEY:USERS_SWGLM]; store password [[ Nsuserdefaults StandardUserdefaults] Setvalue:accarys forkey:users_pwd]; Last multi-use, usually to get a flag, whether to log in. [[Nsuserdefaults Standarduserdefaults] Setvalue:[nsnumber numberwithint:1] forkey:user_loginout];

User remembers account, password

in IOS development

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.