---
title: "connectionShouldUseCredentialStorage(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurlconnectiondelegate/connectionshouldusecredentialstorage(_:)"
---

# connectionShouldUseCredentialStorage(_:)

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

## Declaration

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

## Parameters

- `connection`: The connection sending the message.

## Discussion

Discussion This method is called before any attempt to authenticate is made. If you return 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 true. important: Prior to iOS 7 and OS X v10.9, the connectionShouldUseCredentialStorage: method is never called on delegates that implement the connection(_:willSendRequestFor:) method. In later operating systems, if the delegate implements the 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.

## See Also

### Connection Authentication

- [connection(_:willSendRequestFor:)](foundation/nsurlconnectiondelegate/connection(_:willsendrequestfor:).md)
- [connection(_:canAuthenticateAgainstProtectionSpace:)](foundation/nsurlconnectiondelegate/connection(_:canauthenticateagainstprotectionspace:).md)
- [connection(_:didCancel:)](foundation/nsurlconnectiondelegate/connection(_:didcancel:).md)
- [connection(_:didReceive:)](foundation/nsurlconnectiondelegate/connection(_:didreceive:).md)
