Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

enter image description here

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...

like image 346
Manthan Avatar asked Jul 01 '15 05:07

Manthan


1 Answers

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...

like image 137
Manthan Avatar answered Oct 24 '22 05:10

Manthan