<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLCredential/hasPassword",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLCredential(py)hasPassword"
  },
  "title" : "hasPassword"
}
-->

# hasPassword

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

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

## Discussion

This value is <doc://com.apple.documentation/documentation/Swift/true> if the receiver has a password, <doc://com.apple.documentation/documentation/Swift/false> otherwise.

This method does not attempt to retrieve the password.

If this credential’s password is stored in the user’s keychain, [`password`](/documentation/Foundation/URLCredential/password) may return `nil` even if this method returns <doc://com.apple.documentation/documentation/Swift/true>—getting the password may fail, or the user may refuse access.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)