fetch(withSubscriptionIDs:completionHandler:)
Fetches the specified subscriptions and delivers them to a completion handler.
Declaration
@preconcurrency func fetch(withSubscriptionIDs subscriptionIDs: [CKSubscription.ID], completionHandler: @escaping @Sendable (Result<[CKSubscription.ID : Result<CKSubscription, any Error>], any Error>) -> Void)Parameters
- subscriptionIDs:
The identifiers of the subscriptions to fetch.
- completionHandler:
The closure to execute with the fetch results.
Discussion
The completion handler takes the following parameters:
A Result that contains either a dictionary of fetched subscriptions, or an error if the request fails, such as when the network is unavailable or the device doesn’t have an active iCloud account. When present, the dictionary uses the identifiers you specify in
subscriptionIDsas its keys. The value of each key is a Result that contains either the corresponding fetched subscription, or an error that describes why CloudKit can’t provide that subscription.
For information on a more configurable way to fetch specific subscriptions, see CKFetchSubscriptionsOperation.