Open source China iOS client Learning (12) User Login

Source: Internet
Author: User

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 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

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.