UIActivityItemProvider Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 6.0 and later. |
| Declared in | UIActivityItemProvider.h |
Overview
A UIActivityItemProvider object is a proxy for data passed to an activity view controller. You can use a provider object in situations where you want to make data available for use by an activity but you want to delay providing that data until it is actually needed. For example, you might use a provider object to represent a large video file that needs to be processed before it can be shared to a user’s social media account.
When you initialize a UIActivityViewController object, you can pass a provider object in addition to any other data objects. When the user selects an activity, the activity view controller adds your provider object (which is also an operation object) to an operation queue so that it can begin to gather or process the needed data.
Subclassing Notes
You must subclass UIActivityItemProvider and implement its item method, which is called to generate the item data. You implement this method instead of the normal main method you would implement for an operation object. (The main method calls the item method when the operation object is executed.) Your implementation of the item method should do whatever work is necessary to create and return the data.
Tasks
Initializing the Provider
Accessing the Provider Attributes
-
– item -
placeholderItemproperty -
activityTypeproperty
Properties
activityType
The type of the activity object that is expecting the data. (read-only)
Discussion
The value of this property is nil until the user selects an activity. At that time, the value is set and the provider object is submitted to a queue for execution. Thus, you should access this value only after your object’s item method is called.
Availability
- Available in iOS 6.0 and later.
Declared In
UIActivityItemProvider.hplaceholderItem
The placeholder object you specified at initialization time. (read-only)
Availability
- Available in iOS 6.0 and later.
Declared In
UIActivityItemProvider.hInstance Methods
initWithPlaceholderItem:
Initializes and returns a provider object with the specified placeholder data.
Parameters
- placeholderItem
An object that can stand in for the actual object you plan to create. The contents of the object may be empty but the class of the object must match the class of the object you plan to provide later.
Return Value
An initialized provider object.
Availability
- Available in iOS 6.0 and later.
Declared In
UIActivityItemProvider.hitem
Generates and returns the actual data object.
Discussion
When the actual data object is required, this method is called by the provider object’s infrastructure. Subclasses must override this method and use it to perform whatever work is required to create the data object and return it. You implement this method instead of the normal main method you would implement for operation objects. This method is called on a secondary thread of your app.
Availability
- Available in iOS 6.0 and later.
Declared In
UIActivityItemProvider.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)