Next Page > Hide TOC

NSURLCredential Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.2 with Safari 1.0 installed.
Available in Mac OS X v10.2.7 and later.
Companion guide
Declared in
NSURLCredential.h

Overview

NSURLCredential is an immutable object representing an authentication credential consisting of the user name, a password and the type of persistent storage to use, if any.

Adopted Protocols

NSCopying

Tasks

Creating a Credential

Getting Credential Properties

Class Methods

credentialWithUser:password:persistence:

Creates and returns an NSURLCredential object with a given user name and password using a given persistence setting.

+ (NSURLCredential *)credentialWithUser:(NSString *)user password:(NSString *)password persistence:(NSURLCredentialPersistence)persistence

Parameters
user

The user for the credential.

password

The password for user.

persistence

The persistence setting for the credential.

Return Value

An NSURLCredential object with user name user, password password, and using persistence setting persistence.

Discussion

If persistence is NSURLCredentialPersistencePermanent the credential is stored in the keychain.

Availability
See Also
Declared In
NSURLCredential.h

Instance Methods

hasPassword

Returns a Boolean value that indicates whether the receiver has a password.

- (BOOL)hasPassword

Return Value

YES if the receiver has a password, NO otherwise.

Discussion

This method does not attempt to retrieve the password.

If this credential's password is stored in the user’s keychain, password may return NO even if this method returns YES, since getting the password may fail, or the user may refuse access.

Availability
Declared In
NSURLCredential.h

initWithUser:password:persistence:

Returns an NSURLCredential object initialized with a given user name and password using a given persistence setting.

- (id)initWithUser:(NSString *)user password:(NSString *)password persistence:(NSURLCredentialPersistence)persistence

Parameters
user

The user for the credential.

password

The password for user.

persistence

The persistence setting for the credential.

Return Value

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

Discussion

If persistence is NSURLCredentialPersistencePermanent the credential is stored in the keychain.

Availability
See Also
Declared In
NSURLCredential.h

password

Returns the receiver’s password.

- (NSString *)password

Return Value

The receiver’s password.

Discussion

If the password is stored in the user’s keychain, this method may result in prompting the user for access.

Availability
See Also
Declared In
NSURLCredential.h

persistence

Returns the receiver’s persistence setting.

- (NSURLCredentialPersistence)persistence

Return Value

The receiver’s persistence setting.

Availability
Declared In
NSURLCredential.h

user

Returns the receiver’s user name.

- (NSString *)user

Return Value

The receiver’s user name.

Availability
Declared In
NSURLCredential.h

Constants

NSURLCredentialPersistence

These constants specify how long the credential will be kept.

typedef enum {
   NSURLCredentialPersistenceNone,
   NSURLCredentialPersistenceForSession,
   NSURLCredentialPersistencePermanent
} NSURLCredentialPersistence;

Constants
NSURLCredentialPersistenceNone

Credential won't be stored.

Available in Mac OS X v10.2 and later.

Declared in NSURLCredential.h.

NSURLCredentialPersistenceForSession

Credential will be stored only for this session.

Available in Mac OS X v10.2 and later.

Declared in NSURLCredential.h.

NSURLCredentialPersistencePermanent

Credential will be stored in the user’s keychain and shared with other applications.

Available in Mac OS X v10.2 and later.

Declared in NSURLCredential.h.

Availability
Declared In
NSURLCredential.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-06-28)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.