Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to save and access value from NSUserDefaults

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 414
    Comment on it

    NSUserDefaults is very useful, if you want to save less data and want to access that data whenever you open the application. This data does not delete even after closing the app.

    To save data in NSUserDefaults

    1. NSUserDefaults *usr = [NSUserDefaults standardUserDefaults];
    2. [usr setObject:userNameText.text forKey:@"user"];
    3. [usr setObject:passwordText.text forKey:@"password"];
    4. [usr synchronize];

    To access data from NSUserDefaults

    1. NSUserDefaults *usr = [NSUserDefaults standardUserDefaults];
    2. NSString *user = [usr objectForKey:@"user"];
    3. NSString *pass = [usr objectForKey:@"password"];

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: