在cocoa mac OS X应用程序中分享facebook和twitter中的文本?

时间:2015-07-01 05:43:44

标签: ios objective-c xcode facebook macos

enter image description here

嗨,我在目标c中有一个可可mac应用程序。

在我的应用程序中,我想在Facebook和Twitter上分享文本,就像我们在ios中使用SLComposeViewController一样。

我在google上搜索了很多但是找不到任何mac应用程序。

当我从Facebook分享它时,我看到上面的图像,而对于来自其中一个mac应用程序的Twitter,我看到了相同的图像。

如何为我的mac应用程序实现相同的目标?

提前致谢...

1 个答案:

答案 0 :(得分:7)

我使用@TheAmateurProgrammer对NSSharingServiceNSSharingServicePicker的帮助进行了搜索。

我从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];

希望它能帮助别人......

...谢谢