Previous blog Open source China iOS Client Learning-(11) AES encryption refers to the user name and password saved in the local sandbox, read the user name and password from the local, this is a process?
-(void) Saveusernameandpwd: (NSString *) userName andpwd: (NSString *) pwd
{
nsuserdefaults * settings = [ Nsuserdefaults Standarduserdefaults];
[Settings removeobjectforkey:@ "UserName"];
[Settings removeobjectforkey:@ "Password"];
[Settings Setobject:username forkey:@ "UserName"];
PWD = [Aescrypt encrypt:pwd password:@ "pwd"];
[Settings setobject:pwd forkey:@ "Password"];
[Settings synchronize];
}
The above method uses the Nsuserdefaults class, which also implements the data functionality in a dictionary and saves the data to the local application sandbox, which is suitable for saving small data, such as user login configuration information; This code first defines an object, initializes it, Remove key values for Usename and password objects, prevent data clutter causing interference, and then reset key value information; [Settings synchronize]; Synchronize the key value information to local;
Now let's take a look at this user configuration information in the sandbox
First look at the path to the application sandbox, using the
<span style= "Font-family:comic Sans ms;font-size:18px;" > NSString *homedirectory = Nshomedirectory ();
NSLog (@ "path:%@", homedirectory);</span>
Print Result: Path:/users/dolby/library/application support/iphone simulator/5.1/applications/ 55c49712-ad95-49e0-b3b9-694dc7d26e94
But there is no library in my Dolby User directory, this is because the system hides these file directories, now need to display these hidden files, open the terminal input defaults write Com.apple.finder appleshowallfiles -bool true, and then restart the Finder (not?) Check out the iOS sandbox (sanbox) file and find the 55c49712-ad95-49e0-b3b9-694dc7d26e94 directory under Library/preferences Net.oschina.iosapp.plist file, open it