<!--
{
  "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/Persistence-swift.enum",
  "metadataVersion" : "0.1.0",
  "role" : "Enumeration",
  "symbol" : {
    "kind" : "Enumeration",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:@E@NSURLCredentialPersistence"
  },
  "title" : "URLCredential.Persistence"
}
-->

# URLCredential.Persistence

Constants that specify how long the credential will be kept.

```
enum Persistence
```

## Overview

In iOS, credentials are stored in the app’s keychain, and can be accessed only by that app (and other apps in the same keychain access group, where applicable).

In macOS, credentials are stored in the user’s keychain. The credential’s initial access control list (ACL) allows access only by that app. However, other apps can see that a password exists for a given host, port, and realm combination, and can request that the user grant permission to use that credential.

## Topics

### Persistence strategies

[`NSURLCredentialPersistenceNone`](/documentation/Foundation/URLCredential/Persistence-swift.enum/none)

The credential should not be stored.

[`NSURLCredentialPersistenceForSession`](/documentation/Foundation/URLCredential/Persistence-swift.enum/forSession)

The credential should be stored only for this session.

[`NSURLCredentialPersistencePermanent`](/documentation/Foundation/URLCredential/Persistence-swift.enum/permanent)

The credential should be stored in the keychain.

[`NSURLCredentialPersistenceSynchronizable`](/documentation/Foundation/URLCredential/Persistence-swift.enum/synchronizable)

The credential should be stored permanently in the keychain, and in addition should be distributed to other devices based on the owning Apple ID.

## Relationships

### Conforms To

[`Hashable`](/documentation/Swift/Hashable)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`Sendable`](/documentation/Swift/Sendable)

[`Equatable`](/documentation/Swift/Equatable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)