How do I store a password in Cocoa preferences?

cocoa, nsuserdefaults

Solution

Passwords should be stored in the Keychain. You should probably look at the Keychain Services Programming Guide to begin with. The Keychain exists on both iOS and OS X platforms.

Problem

I was going to store a password in my Cocoa application in the `NSUserDefaults` but then I realized that it is stored in plain text. How do you store password credentials for Cocoa applications?

Original source