To subclass or not to subclass, that is the question
Gerriet M. Denkmann
Documentation about UIActivity:
“You should subclass UIActivity only if you want to provide custom services to the user. "
“This class must be subclassed before it can be used. "
So what? Kind of confusing.
Gerriet M. Denkmann
On 9 Oct 2018, at 10:47, Gerriet M. Denkmann <g@...> wrote:
Maybe it works like this:
NSArray *activityItems = @[ someUrl ];
UIActivityViewController *vc = [ [UIActivityViewController alloc] initWithActivityItems: activityItems
// If (and only if) one wants to provide custom services to the user, then applicationActivities must *not* be nil, but contain one or more subclasses of UIActivity
vc.excludedActivityTypes = @[ everything except UIActivityTypeAirDrop ];
[ self presentViewController: vc …];
My current problem:
The UIActivityViewController has AirDrop (as it should) but it also has some other things, which do *not* make sense for my app at all:
One row with:
Copy to Documents
Copy to Files
Copy to PDF Expert
… More (Where one can switch on “Add to Notes”)
and another row with:
… More (Where one can switch on “Save to Files” and “Save in LINE Keep”)
I really just want AirDrop and nothing else.
How can this be accomplished?
One final point:
iOS → macOS:
My iOS device can copy “someUrl” to the Downloads folder of the recipient. Which is kind of ok.
But is there a way to specify a more specific destination?
Like the Application Support Folder of some app?
iOS → iOS
Here the AirDrop should only be done to another copy of my app.
Can this somehow be specified?
On Oct 8, 2018, at 20:47 , Gerriet M. Denkmann <g@...> wrote:
It looks to me like the first quoted sentence is just poorly worded. I think it’s saying you should *use a UIActivity subclass* if you want to provide custom services.
Note that UIActivity is described in the documentation as an abstract class, so I doubt there’s any use-case where you’d instantiate one literally of that class.