ios - Share text to Facebook Objective-C -


i'm trying share text on facebook via ios application. i've managed working in swift written application this:

@ibaction func shareaction(sender: anyobject) {  if slcomposeviewcontroller.isavailableforservicetype(slservicetypefacebook){     var facebooksheet:slcomposeviewcontroller = slcomposeviewcontroller(forservicetype: slservicetypefacebook)     facebooksheet.setinitialtext("preadded text")     self.presentviewcontroller(facebooksheet, animated: true, completion: nil)  } else {      var alert = uialertcontroller(title: "accounts", message: "please login facebook account share.", preferredstyle: uialertcontrollerstyle.alert)     alert.addaction(uialertaction(title: "ok", style: uialertactionstyle.default, handler: nil))     self.presentviewcontroller(alert, animated: true, completion: nil)  } } 

however, code written in objective-c. question is, there similar way of writing in objective-c?

you can achieve implementing social framework

-(void)fbbutton {     if ([slcomposeviewcontroller isavailableforservicetype:slservicetypefacebook]) {         fbslcomposeviewcontroller = [slcomposeviewcontroller composeviewcontrollerforservicetype:slservicetypefacebook];         [fbslcomposeviewcontroller addimage:someimage];         [fbslcomposeviewcontroller setinitialtext:@"some text"];         [self presentviewcontroller:fbslcomposeviewcontroller animated:yes completion:nil];          fbslcomposeviewcontroller.completionhandler = ^(slcomposeviewcontrollerresult result) {             switch(result) {                 case slcomposeviewcontrollerresultcancelled:                     nslog(@"facebook: cancelled");                     break;                 case slcomposeviewcontrollerresultdone:                     nslog(@"facebook: shared");                     break;             }         };     }     else {         uialertview *fberror = [[uialertview alloc] initwithtitle:@"facebook unavailable" message:@"sorry, we're unable find facebook account on device.\nplease setup account in devices settings , try again." delegate:self cancelbuttontitle:@"close" otherbuttontitles:nil];         [fberror show];     } } 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -