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

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

    To access data from NSUserDefaults

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

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: