0

For example, the documentation for UIActivityTypeAirDrop states

When using this service, you can provide NSString, NSAttributedString, UIImage, ALAsset, and NSURL objects as data for the activity items. You may also specify NSURL objects whose contents use the assets-library scheme. You may also provide NSArray or NSDictionary objects that contain the listed data types.

But how do we know what exactly is going to be done with each of the data objects? Do we just need to experiment to find out? Same for the other UIActivity types, none of them say what is specifically done with the objects.

Marty
  • 5,926
  • 9
  • 53
  • 91

1 Answers1

0

Unfortunately the documentation for this controller is not that comprehensive and there are not too many details on this. Experimentation is pretty much what I've ended up doing. Some of them are common sense though, such as "Save to Camera Roll" requiring an image object. Most of the others will try to use whatever you give them (URL, text, image, etc).

I would implement your own UIActivityItemSource to pass into the controller, and return exactly the media you want for each individual activity item type so that there is no ambiguity in what will actually get passed to the user.

Dima
  • 23,484
  • 6
  • 56
  • 83
  • 2
    Actually, when using UIActivityItemSource you need to make sure that the the object's class type returned from the placeholderItem protocol method matches the class type of the return value from the itemForActivityType. So instead what you should do is create one UIActivityItemSource object for each type you want to support, and then depending on the chosen activity return nil in the itemForActivityType method. Just make sure that for any chosen activity at least one of the UIActivityItemSource objects return a non-nil value, otherwise bad things can happen. – ccjensen Sep 25 '13 at 16:59
  • Correct. Good addition. – Dima Sep 25 '13 at 18:45