Instance Method

initWithUser:password:persistence:

Creates a URL credential instance initialized with a given user name and password, using a given persistence setting.

Declaration

- (instancetype)initWithUser:(NSString *)user password:(NSString *)password persistence:(NSURLCredentialPersistence)persistence;

Parameters

user

The user for the credential.

password

The password for user.

persistence

A NSURLCredentialPersistence value indicating whether the credential should be stored permanently, for the duration of the current session, or not at all.

Return Value

An instance of NSURLCredential, initialized with user name user, password password, and using persistence setting persistence.

Discussion

If persistence is NSURLCredentialPersistencePermanent, the credential is stored in the keychain. If persistence is NSURLCredentialPersistenceSynchronizable, it is also stored to the user’s other devices.

See Also

Creating a Credential

+ credentialForTrust:

Creates a URL credential instance for server trust authentication with a given accepted trust.

+ credentialWithUser:password:persistence:

Creates a URL credential instance for internet password authentication with a given user name and password, using a given persistence setting.

+ credentialWithIdentity:certificates:persistence:

Creates a URL credential instance for resolving a client certificate authentication challenge.

- initWithIdentity:certificates:persistence:

Creates a URL credential instance for resolving a client certificate authentication challenge.

- initWithTrust:

Creates a URL credential instance for server trust authentication, initialized with a accepted trust.

NSURLCredentialPersistence

Constants that specify how long the credential will be kept.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software