<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSPersistentStoreDescription/setOption(_:forKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPersistentStoreDescription(im)setOption:forKey:"
  },
  "title" : "setOption(_:forKey:)"
}
-->

# setOption(_:forKey:)

Sets an option on the store.

```
func setOption(_ option: NSObject?, forKey key: String)
```

## Parameters

`option`

The value to be set for an option on the store.

`key`

The key of the value to be set for an option on the store.

## Discussion

If a value was previously set for the given option, that value is replaced with the given value. Note that the keys are case-sensitive. For a list of the available options, see [`NSPersistentStoreCoordinator`](/documentation/CoreData/NSPersistentStoreCoordinator).

---

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)