Search code examples
iosobjective-cnsuserdefaultskeychain

Keychain or NSUserDefaults? Which one to use?


Can you suggest a good, safe way to save and show the username and password of the user so they can be shown on the login page?

I know that using NSUserDefaults is not very secure so it's not a good way to use it for storing the password for accessing my app.

Can you tell me which third-party (in Objective-C) methods and libraries can I use to ensure safe results?


Solution

  • You should use NSURLCredential, it will save username and password in the keychain in just two lines of code.

    This is detailed answer