Hi folks,
In this section we are going to explore new Apple framework "Twitter.framework" which is available from iOS 5. There are lots of things you can track with this framework like tweeting from your app, extracting profile and pictures of others from within your app etc. But, for this blog we are only going to send out tweets from our iOS apps. Along with the tweet text, i will even show you how to add image/pictures and links with the tweet. Lets get started then:
1. Add Twitter.framework and Accounts.framework to your project. One thing to be noted is if you are going to support your app for below iOS 5 too then you have to weak link the Twitter framework since it is not available for older versions. For this, simply click on the Twitter.Framework on the Build Phases of your target settings and change the "Required" drop down to "Optional".
2. Include #import <Twitter/Twitter.h> in your .h file.
3. Now, lets write a code for tweeting in a custom method :
In this section we are going to explore new Apple framework "Twitter.framework" which is available from iOS 5. There are lots of things you can track with this framework like tweeting from your app, extracting profile and pictures of others from within your app etc. But, for this blog we are only going to send out tweets from our iOS apps. Along with the tweet text, i will even show you how to add image/pictures and links with the tweet. Lets get started then:
1. Add Twitter.framework and Accounts.framework to your project. One thing to be noted is if you are going to support your app for below iOS 5 too then you have to weak link the Twitter framework since it is not available for older versions. For this, simply click on the Twitter.Framework on the Build Phases of your target settings and change the "Required" drop down to "Optional".
2. Include #import <Twitter/Twitter.h> in your .h file.
3. Now, lets write a code for tweeting in a custom method :
-(IBAction)sendTweetsFromYourApp : (id) sender {
if(NSClassFromString(@"TWTweetComposeViewController")!= nil){ // this if call is required if you are going to support your app for older than iOS 5, this simply checks whether this Tweet class is available or not in running device (we do have to weak link Tweeter framework as described above for older iOS,But for app targeting iOS 5 and later this check is not required.)