Search code examples
macosuikitosx-mavericksappkit

Is there something equivalent of UIActivityViewController in OSX?


I am migrating an application from iOS to OSX, Is there something equivalent of UIActivityViewController in OSX . For things like Facebook, Twitter, mail , Message sharing, I need to do something like;

NSArray *activityItems = [NSArray arrayWithObjects:shareString, shareImage, shareUrl, nil];


UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];

activityViewController.excludedActivityTypes = @[UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll];


activityViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:activityViewController animated:YES completion:nil];

How can you achieve this in OSX?


Solution

  • For OSX , we can use the NSSharingServicePicker which is very similar to UIActivityViewController for iOS:

    NSSharingServicePicker *sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:urls];
    sharingServicePicker.delegate = self;
    
    [sharingServicePicker showRelativeToRect:[sender bounds]
                                          ofView:sender
                                   preferredEdge:NSMinYEdge];