<!--
{
  "availability" : [
    "iOS: 9.3.0 -",
    "iPadOS: 9.3.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "swift: 4.2.0 -",
    "tvOS: 9.2.0 -",
    "visionOS: -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CloudKit",
  "identifier" : "/documentation/CloudKit/CKContainer/fetchLongLivedOperation(withID:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "CloudKit"
    ],
    "preciseIdentifier" : "s:So11CKContainerC8CloudKitE23fetchLongLivedOperation6withID17completionHandlerySS_ySo11CKOperationCSg_s5Error_pSgtctF"
  },
  "title" : "fetchLongLivedOperation(withID:completionHandler:)"
}
-->

# fetchLongLivedOperation(withID:completionHandler:)

Fetches the long-lived operation for the specified operation ID.

```
@preconcurrency func fetchLongLivedOperation(withID operationID: CKOperation.ID, completionHandler: @escaping @Sendable (CKOperation?, (any Error)?) -> Void)
```

## Parameters

`operationID`

The operation’s ID.

`completionHandler`

The closure to execute with the fetch results.

## Discussion

The closure doesn’t return a value and takes the following parameters:

- The long-lived operation. If the operation completes, or your app or the system cancels it, this parameter is `nil`.
- An error if a problem occurs, or `nil` if CloudKit successfully retrieves the operation.

A long-lived operation is one that continues to run after the user closes your app. When a long-lived operation completes, the system calls its completion block to notify you.

After setting callback blocks on the returned long-lived operation, and starting the returned long-lived operation on an operation queue, the operation invokes all callbacks made while your app was closed.

---

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)