Instance Method


The activity item object that can be used by an activity view controller.


func activityItemSource() -> UIActivityItemSource


Use activityItemSource(), an object that conforms to the UIActivityItemSource protocol, when you want to include the CloudKit Sharing action as one of the action items in an instance of UIActivityViewController.

Including activityItemSource() in an activity view controller can be useful when your app's user interface does not have space to display a button dedicated to CloudKit Sharing. For instance, say your app already has an action button that lets the user share data with social media sites or other apps via an activity view controller. If you include activityItemSource() as one of the activity view controller's action items, the controller includes the action as a user-selectable option, thus eliminating the need for a second button in your app's user interface.

Listing 1

Include the sharing controller's activity item in an activity view controller.

let items = [cloudSharingController.activityItemSource()]
let activityController = UIActivityViewController(activityItems: items, applicationActivities: [])
present(activityController, animated: true, completion: {})