0

In my app there is use name and password field to login and there is check mark .what I have to do is .i want to remember the user name and password if user press the check mark that means if again user press the app he will direct to next screen not as login screen. If user didn't press the check mark don't want to remember username and password.

  • 2
    Possible duplicate of [iOS persistent storage strategy](http://stackoverflow.com/questions/8727508/ios-persistent-storage-strategy) – Hackerman Sep 16 '16 at 19:12
  • If you don't care about security, you could store the username and password in NSUserDefaults. If you want to remember the login and password in a secure fashion, I recommend using Keychain Services. https://developer.apple.com/library/content/documentation/Security/Conceptual/keychainServConcepts/02concepts/concepts.html – TyR Sep 16 '16 at 19:14
  • @TyR Since this is about a username and password, security is important. – rmaddy Sep 16 '16 at 20:17
  • @rmaddy I know it's important, but sometimes people don't care about important things. That's why I said "if you don't care about security". – TyR Sep 16 '16 at 20:19
  • @TyR My comment was really meant for the OP. They need to understand that it is important. – rmaddy Sep 16 '16 at 20:21

2 Answers2

1

Alternative to NSUserDefault, which save values permanently in keychain.

Grab the four files (.h and .m) PDKeychainBindingsController folder and add them to your xCode project.

  • Import the header file. #import "PDKeychainBindings.h"
  • Set object:- [[PDKeychainBindings sharedKeychainBindings] setObject:@"Pardeep" forKey:@"key_name"];
  • Get object from key:-NSString *folderPath=[[PDKeychainBindings sharedKeychainBindings] objectForKey:@"key_name"];

Find the details in my blog post.

pkc456
  • 8,350
  • 38
  • 53
  • 109
0

There are many different ways to save your data to disk in iOS – raw file APIs, Property List Serialization, SQLite, Core Data, NSCoding.

use NSURLCredential. Indeed NSURLCredential is much simpler to use, as it allows you to store both username and password. check following link for more info:
1. AFNetworking and Cookies
2.What is the best way to maintain the login credentials in iOS?

Community
  • 1
  • 1
Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
  • It's a password. Security is important. Only use `NSUserDefaults` or many of these other options if the password is properly hashed. DO NOT store a plaintext password using any of these options. – rmaddy Sep 16 '16 at 20:18
  • you are right rmaddy security is one of major factor. above all ways are just for data persistence ways. but for security keychain is helpfull – Sangram Shivankar Sep 16 '16 at 20:51