Save username and password for transfer

I have a text box

Number and password

I do not know how to save these settings, and then read them when the application starts checking whether they were installed or not.

thank

Mason

+5
source share
2 answers

Save:

[[NSUserDefaults standardUserDefaults] setValue:_email forKey:@"email"];
[[NSUserDefaults standardUserDefaults] setValue:_password forKey:@"password"];
[[NSUserDefaults standardUserDefaults] synchronize];

For reading:

_email = [[NSUserDefaults standardUserDefaults] stringForKey:@"email"];
_password = [[NSUserDefaults standardUserDefaults] stringForKey:@"password"];

In your case:

[[NSUserDefaults standardUserDefaults] setValue:Number.text forKey:@"Number"];

and

NSString * number = [[NSUserDefaults standardUserDefaults] stringForKey:@"Number"];

A “key” is usually hardcoded and acts like a “variable name” for things in storage (typical name and value pairs, such as a dictionary).

Check if the value is set or not; after reading it:

if (number) ...
+5
source

, . / NSUserDefaults, , .

iPhone, . , Github, :

http://github.com/ldandersen/scifihifi-iphone/tree/master/security

+13

All Articles