Cover by Vandad Nahavandipoor

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

9.11. Integrating Twitter Functionality into Your Apps

Problem

You want to integrate Twitter functionality into your iOS apps.

Solution

Use the Twitter framework.

Discussion

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

@end

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 ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required