Twitter post with cocos2d 2.x

  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Here is what i am using for tweets:

tweet

You need the twitter.framework and
#import <Twitter/Twitter.h>

-(void) postTweet
{
    AppController * app = (((AppController*) [UIApplication sharedApplication].delegate));
    TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];

    [tweetViewController setInitialText:@"blablabalbalblabla"];

    [tweetViewController setCompletionHandler:
        ^(TWTweetComposeViewControllerResult result) 
        {
            dispatch_async(dispatch_get_main_queue(), ^{
            {
               if (result == TWTweetComposeViewControllerResultDone)
               {       
                   //success
               }
               else if(result == TWTweetComposeViewControllerResultCancelled)
               {
                   //cancelled
               }
            }

            [app.navController dismissModalViewControllerAnimated:YES];
         });
     }];

     [app.navController presentModalViewController:tweetViewController animated:YES];
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>