An abstract class that you subclass to implement app-specific services.


@interface UIActivity : NSObject


You should subclass UIActivity only if you want to provide custom services to the user. A service takes data that is passed to it, does something to that data, and returns the results. For example, a social media service might take whatever text, images, or other content is provided to it and post them to the user’s account. Activity objects are used in conjunction with a UIActivityViewController object, which is responsible for presenting services to the user.

The system already provides support for many standard services and makes them available through the UIActivityViewController object. For example, the standard activity view controller supports emailing data, posting items to one of the user’s social media accounts, and several other options. You do not have to provide custom services for any of the built-in types.

Subclassing Notes

This class must be subclassed before it can be used. The job of an activity object is to act on the data provided to it and to provide some meta information that iOS can display to the user. For more complex services, an activity object can also display a custom user interface and use it to gather additional information from the user.

Methods to Override

When subclassing, you must always override the following methods and use them to provide information about your service:

If your canPerformWithActivityItems: method indicates that your subclass is able to operate on the specified data, the active UIActivityViewController object displays your service to the user. When the user selects your service, the activity view controller calls the prepareWithActivityItems: method followed by only one of these methods:

  • activityViewController—Returns a view controller to present to the user. If your service requires additional input from the user, override this method and use it to return the view controller object responsible for presenting your custom UI. (You do not need to present the view controller yourself.) After your view controller object gathers the needed input, it is responsible for initiating the task associated with the service.

  • performActivity—Performs the service without displaying any additional UI. If your service does not need additional input from the user, override this method and perform the task associated with the service.


Getting the Activity Information


Returns the category of the activity, which may be used to group activities in the UI.


Activities have a defined category, and the activity UI may show activities grouped by category.


An identifier for the type of service being provided.


Activity types for which the system has built-in support.


A user-readable string describing the service.


An image that identifies the service to the user.

Performing the Activity

- canPerformWithActivityItems:

Returns a Boolean indicating whether the service can act on the specified data items.

- prepareWithActivityItems:

Prepares your service to act on the specified data.


Returns the view controller to present to the user.

- performActivity

Performs the service when no custom view controller is provided.

- activityDidFinish:

Notifies the system that your activity object has completed its work.


Inherits From

See Also

Activities Interface


A view controller that you use to offer standard services from your app.


A proxy for data passed to an activity view controller.


A set of methods used by an activity view controller to retrieve the data items to act on.