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:
Click on your project icon in Xcode.
Select the target to which you want to add the Twitter framework.
On the top, select Build Phases.
Expand the Link Binary with Libraries box to see all the frameworks that are currently linked to your target.
Click on the little + button at the bottom-left corner of the “Link Binary with Libraries” box.
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 ...
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.