Skip to content

Instantly share code, notes, and snippets.

@KAMEDAkyosuke
Created September 21, 2017 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KAMEDAkyosuke/a447d30f44d8150c747f7f666078551b to your computer and use it in GitHub Desktop.
Save KAMEDAkyosuke/a447d30f44d8150c747f7f666078551b to your computer and use it in GitHub Desktop.
NSMutableArray<id> *items = [NSMutableArray array];
NSURL *url = [NSURL URLWithString:@"https://www.google.co.jp"];
NSString *text = @"hello world";
[items addObject:url];
[items addObject:text];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:items
applicationActivities:nil];
// select copy action
[self presentViewController:activityViewController
animated:YES
completion:^{
// then check pasteboard
NSArray<NSString*> *strings = [[UIPasteboard generalPasteboard] strings];
NSLog(@"%@", strings); /*
* (
* "https://www.google.co.jp\nhello world",
* "https://www.google.co.jp"
* )
* WTF!?
*/
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment