<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSUbiquitousKeyValueStore/set(_:forKey:)-7tt20",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSUbiquitousKeyValueStore(im)setLongLong:forKey:"
  },
  "title" : "set(_:forKey:)"
}
-->

# set(_:forKey:)

Sets the value of the specified key to a 64-bit integer value.

```
func set(_ value: Int64, forKey aKey: String)
```

## Parameters

`value`

The integer value to save to the iCloud key-value store.

`aKey`

The key to associate with the value.

## Discussion

This method places the integer value in an [`NSNumber`](/documentation/Foundation/NSNumber) type before writing the
key and value to the store.

---

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)