try to get rid of the alloc and init string SLComposeViewController, because you recreate with the class method composeViewControllerForServiceType, which returns an object with auto-implementation ..... (if in ARC)
So it will look like this:
-(IBAction)post:(id)sender { if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { mySocialComposer = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; [mySocialComposer setInitialText:@"Hello World"]; [self presentViewController:mySocialComposer animated:YES completion:nil]; } [mySocialComposer setCompletionHandler:^(SLComposeViewControllerResult result){ NSString *outout = [[NSString alloc] init]; switch (result) { case SLComposeViewControllerResultCancelled: outout = @"Post Cancled"; break; case SLComposeViewControllerResultDone: outout = @"Post Done"; default: break; } UIAlertView *myalertView = [[UIAlertView alloc]initWithTitle:@"FaceBook" message:outout delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; [myalertView show]; }];
Otherwise, the code looks good to me if you are not doing something with this instance of mySocialComposer somewhere else
source share