---
title: hasPassword
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/urlcredential/haspassword
---

# hasPassword

A Boolean value that indicates whether the credential has a password.

## Declaration

```swift
var hasPassword: Bool { get }
```

## Discussion

Discussion This value is true if the receiver has a password, false otherwise. This method does not attempt to retrieve the password. If this credential’s password is stored in the user’s keychain, password may return nil even if this method returns true—getting the password may fail, or the user may refuse access.

## See Also

### Getting credential properties

- [user](foundation/urlcredential/user.md)
- [certificates](foundation/urlcredential/certificates.md)
- [password](foundation/urlcredential/password.md)
- [identity](foundation/urlcredential/identity.md)
- [persistence](foundation/urlcredential/persistence-swift.property.md)
- [URLCredential.Persistence](foundation/urlcredential/persistence-swift.enum.md)
