简体   繁体   中英

Share text in facebook and twitter in cocoa mac OS X application?

在此输入图像描述

Hi, I am having a cocoa mac application in objective c.

In my app, I want to share text on facebook and twitter like we do in ios with SLComposeViewController.

I searched a lot on google but couldn't find anything for mac application.

I see the above image when I share it from facebook and same for the twitter from one of the mac apps.

How can I achieve the same for my mac application?

Thanks in advance...

I searched it with @TheAmateurProgrammer's help about NSSharingService and NSSharingServicePicker .

I found the solution from the link .

// Facebook

NSArray* array = @[ @"myText"];

NSSharingService* sharingServiceFB = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnFacebook];

[sharingServiceFB performWithItems:array];

// Twitter

NSArray* array = @[ @"myText"];

NSSharingService* sharingServiceFB = [NSSharingService sharingServiceNamed:NSSharingServiceNamePostOnTwitter];

    [sharingServiceFB performWithItems:array];

Hope it helps someone else also...

Thanks...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM