Item Providers

Extending the previous approach, the UIActivityItemProvider class conforms to the UIActivityItemSource protocol and enables you to delay passing data. It’s a type of operation (NSOperation) that offers you the flexibility to manipulate data before sharing. For example, you might need to process a large video file before it can be uploaded to a social sharing site, or you might need to subsample some audio from a larger sequence.

Subclass the provider class and implement the item method. This takes the place of the main method you normally use with operations. Generate the processed data, safe in the knowledge that the method will run asynchronously without blocking your user’s interactive experience.

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.