Question

I am creating a program in xCode that basically lets you post some something to your twitter. Everything works except that i am trying to figure a way to post a hypertext that will lead to say google. Forexample i want the words wwww.google.com to lead to google when i click it..Any help is appreciated. Thanks

This is the code

-(void)tweetTapped{
    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
    {
        SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
        [tweetSheet setInitialText:@"Post to Twitter :) www.google.com"];


        [self presentViewController:tweetSheet animated:YES completion:nil];
    }
    else
    {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"Sorry"
                                  message:@"You can't send a tweet right now, make sureyour device has an internet connection and you haveat least one Twitter account setup"
                                  delegate:self
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
        [alertView show];
    }
}
Was it helpful?

Solution

You can't use hypertext in a tweet, but if you include a URL it should be automatically linked for you by Twitter. Twitter will generally use a URL shortener too. So just use a format like this:

NSString *tweet = @"This is a link to http://google.com";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top