Social Framework on iOS8 using Swift Language

It's very simple, I am currently following this Topic: Social Framework iOS 8 swift and I have successfully finished it. Here is my complete code in Swift:





On a ViewController.swift:


@IBAction func shareFB(sender : AnyObject) {
    if(SLComposeViewController.isAvailableForServiceType(SLServiceTypeFacebook))
    {
        var SocialMedia :SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeFacebook)

        SocialMedia.completionHandler = {
            result -> Void in


            var getResult = result as SLComposeViewControllerResult;
            switch(getResult.toRaw()) {
            case SLComposeViewControllerResult.Cancelled.toRaw(): println("Cancelled")
            case SLComposeViewControllerResult.Done.toRaw(): println("It's Work!")
            default: println("Error!")
            }
            self.dismissViewControllerAnimated(true, completion: nil)
        }
        self.presentViewController(SocialMedia, animated: true, completion: nil)
        SocialMedia.setInitialText("Test a Post on Facebook")
    }


}
Run your application, It's work fine!



Comments

  1. Can u plz give all project? I have errors:
    2014-08-16 17:53:46.513 Share[8376:184602] Discovered extensions: {(
    {id = com.apple.share.Flickr.post},
    {id = com.apple.share.Twitter.post},
    {id = com.apple.share.TencentWeibo.post},
    {id = com.apple.mobileslideshow.StreamShareService},
    {id = com.apple.share.Facebook.post},
    {id = com.apple.share.Vimeo.post},
    {id = com.apple.share.SinaWeibo.post}
    )} for attributes: {
    NSExtensionPointName = "com.apple.share-services";
    }

    ReplyDelete

Post a Comment