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