Adding a password to the keychain | Apple Developer Documentation

Add network credentials to the keychain on behalf of the user.