0

I am using subclass of UIActivityViewController to show custom UIActivities.

When Controller is showing, I am getting

Unknown activity items supplied: (
    "<MyClass: somehash>"
)

in my logs.

MyClass subclasses NSObject and is passed to new ViewController invoked by tap on my UIActivity.

I tried to implement protocol UIActivityItemSource on MyClass, but it didn't solve the problem.

MyClass object is passed in array to [UIActivityViewController init] as activityItems parameter, and it shouldn't be a problem, as documentation says only:

The array of data objects on which to perform the activity. The type of objects in the array is variable and dependent on the data your application manages. For example, the data might consist of one or more string or image objects representing the currently selected content.

Edit:

This is the code I can share:

MyClass *myDataObject = some data...

...

NSMutableArray *activityItems = [NSMutableArray arrayWithCapacity:3];
[activityItems addObject:NSLocalizedString(@"default_activity_message", nil)];
[activityItems addObject:someURL];
[activityItems addObject:myDataObject];

NSMutableArray *customActivities = [NSMutableArray arrayWithCapacity:1];
[customActivities addObject:[MyActivity new]];

MyActivityViewController *activityViewController = 
    [[MyActivityViewController alloc] initWithActivityItems:activityItems 
                                      applicationActivities:customActivities];

[self presentViewController:activityViewController animated:YES completion:nil];

1 Answers1

0

You should subclass UIActivity, not UIActivityViewController. And then pass in the subclass in applicationActivities:...

// Create activity view controller
UIActivityViewController* vc = [[UIActivityViewController alloc] initWithActivityItems:@[myDataItem] applicationActivities:@[myActivityAction]];
jjv360
  • 4,120
  • 3
  • 23
  • 37
  • Yes, I am doing that. I have my own UIActivityViewController and I am passing it my custom UIAcitivities and data objects. Only problem is that data objects are "unknown". – Adam Dziedzic Feb 24 '15 at 14:16