<!--
{
  "availability" : [
    "macOS: 10.12.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSItemProvider/registerCloudKitShare(_:container:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSItemProvider(im)registerCloudKitShare:container:"
  },
  "title" : "registerCloudKitShare(_:container:)"
}
-->

# registerCloudKitShare(_:container:)

Registers a CloudKit share for the user to modify.

```
func registerCloudKitShare(_ share: CKShare, container: CKContainer)
```

## Parameters

`share`

The CloudKit share to modify.

`container`

The CloudKit container that stores the shared records.

## Discussion

Use this method when the CloudKit share already exists on the server and you want to update it. The behavior of the sharing service depends on the role of the current user. An owner can edit the share’s configuration, which includes managing participants and their permissions. A participant can view the share’s configuration and choose to stop participating.

If you’re unsure which container to use, fetch the share’s metadata using <doc://com.apple.documentation/documentation/CloudKit/CKFetchShareMetadataOperation>. Then initialize an instance of <doc://com.apple.documentation/documentation/CloudKit/CKContainer> using the metadata’s <doc://com.apple.documentation/documentation/CloudKit/CKShare/Metadata/containerIdentifier> property.

Use the <doc://com.apple.documentation/documentation/AppKit/NSCloudSharingServiceDelegate> protocol to respond to any changes the sharing service makes.

> Note:
> To create a new share, use the ``doc://com.apple.foundation/documentation/Foundation/NSItemProvider/registerCloudKitShare(preparationHandler:)`` method instead.

The following example shows how to create an item provider with an existing share. It then invokes the cloud-sharing service with the provider and presents the share’s configuration to the user.

```swift
func modifyShare(_ share: CKShare, in container: CKContainer) {

    // Create an item provider and register a share that
    // already exists on the server.
    let itemProvider = NSItemProvider()
    itemProvider.registerCloudKitShare(share, container: container)
        
    // Create and invoke the cloud-sharing service to
    // present the share configuration to the user.
    if let service = NSSharingService(named: .cloudSharing),
       service.canPerform(withItems: [itemProvider]) {
        service.perform(withItems: [itemProvider])
    }
}
```

---

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)