This is almost the same answer as llario, but follows Apple docs instructions and employs defensive coding with some additional error checking.
#import <Social/Social.h>
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) {
SLComposeViewController *composeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
if (composeViewController) {
[composeViewController addImage:[UIImage imageNamed:@"MyImage"]];
[composeViewController addURL:[NSURL URLWithString:@"http://www.google.com"]];
NSString *initialTextString = @"Check out this Tweet!";
[composeViewController setInitialText:initialTextString];
[composeViewController setCompletionHandler:^(SLComposeViewControllerResult result) {
if (result == SLComposeViewControllerResultDone) {
NSLog(@"Posted");
} else if (result == SLComposeViewControllerResultCancelled) {
NSLog(@"Post Cancelled");
} else {
NSLog(@"Post Failed");
}
}];
[self presentViewController:composeViewController animated:YES completion:nil];
}
}