<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLConnectionDelegate/connectionShouldUseCredentialStorage(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLConnectionDelegate(im)connectionShouldUseCredentialStorage:"
  },
  "title" : "connectionShouldUseCredentialStorage(_:)"
}
-->

# connectionShouldUseCredentialStorage(_:)

Sent to determine whether the URL loader should use the credential storage for authenticating the connection.

```
optional func connectionShouldUseCredentialStorage(_ connection: NSURLConnection) -> Bool
```

## Parameters

`connection`

The connection sending the message.

## Discussion

This method is called before any attempt to authenticate is made.

If you return <doc://com.apple.documentation/documentation/Swift/false>, the connection does not consult the credential storage automatically, and does not store credentials. However, in your connection:didReceiveAuthenticationChallenge: method, you can consult the credential storage yourself and store credentials yourself, as needed.

Not implementing this method is the same as returning <doc://com.apple.documentation/documentation/Swift/true>.

> Important:
> Prior to iOS 7 and OS X v10.9, the `connectionShouldUseCredentialStorage:` method is never called on delegates that implement the ``doc://com.apple.foundation/documentation/Foundation/NSURLConnectionDelegate/connection(_:willSendRequestFor:)`` method.
> 
> In later operating systems, if the delegate implements the ``doc://com.apple.foundation/documentation/Foundation/NSURLConnectionDelegate/connection(_:willSendRequestFor:)`` method, the `connectionShouldUseCredentialStorage:` method is called *only* if the app’s deployment target is at least iOS 7 or OS X v10.9.

---

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)