9.11. Integrating Twitter Functionality into Your Apps


You want to integrate Twitter functionality into your iOS apps.


Use the Twitter framework.


To be able to integrate Twitter functionality into our iOS apps, we need to use the Twitter framework. So first we need to add this framework to our app. Follow these steps to add the Twitter framework to your app:

  1. Click on your project icon in Xcode.

  2. Select the target to which you want to add the Twitter framework.

  3. On the top, select Build Phases.

  4. Expand the Link Binary with Libraries box to see all the frameworks that are currently linked to your target.

  5. Click on the little + button at the bottom-left corner of the “Link Binary with Libraries” box.

  6. Select Twitter.framework from the list and then press the Add button.

Good! Now you have the Twitter framework linked to your app. The next thing you need to do is import the appropriate header file into your view controller’s header file:

#import <UIKit/UIKit.h>
#import <Twitter/Twitter.h>

@interface Integrating_Twitter_Functionality_Into_Your_AppsViewController
           : UIViewController


The next step is to instantiate an object of type TWTweetComposeViewController, which will take care of tweeting for you. This is just a view controller that you can display on top of your view controller. I have defined a property for our view controller for this:

#import <UIKit/UIKit.h>
#import <Twitter/Twitter.h>

@interface Integrating_Twitter_Functionality_Into_Your_AppsViewController
           : UIViewController ...

Get iOS 6 Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.