Showing posts with label twitter integration. Show all posts
Showing posts with label twitter integration. Show all posts

Monday, October 24, 2011

Example Project: Creating a TwitPic Replacement with the Twitter Framework in iOS 5

I was doing research into different Twitter iPhone apps to determine what people liked about each one and I stumbled upon (and purchased) the TwitPic app. I realized that you can easily create a similar app using the Twitter Framework in iOS 5. I don't have time for a step-by-step tutorial right now, but I provided the entire project for download here.












Project Available to Download: here.

Note: I do not own any of the Twitter pictures and I am in no way affiliated with Twitter.

Note: The project isn't "finished" yet, but it's a good starting point.









Example Project: Using iOS 5 Twitter API to Find Foursquare Checkins (Unfinished)

Download Project: here









Sunday, October 23, 2011

iOS 5 Tweeting Apple Sample Code (Errors?) + How to Parse JSON With NSJSONSerialization

     I was planning on creating an extensive tutorial a couple weeks ago on how to use the Twitter API in iOS 5, but I was running into errors and I thought I would tell you what my errors were and how I resolved them.

Apple Sample Code: here

1. I downloaded the Tweeting Apple sample code and ran the package and noticed they had an example on how to download public timelines in JSON format using the new TWRequest class.


2. In the sample code they used the NSJSONSerialization to create the publicTimeline NSDictionary. I tried to create a new array NSArray *keys = [publicTimeline allKeys]; and the program would crash.

This is the error:





3. Naturally, the first thing I did was ask my friend who works at Apple (comparative advantage) and he really didn't know what was going on so I was stuck and trying different things for about a week. I then did some searching and reading in forums and someone was having a similar error with NSMutableArrays being converted into NSCFArrays and then someone on stack overflow suggested creating a new array with an array and it sparked an idea for me to do the same.

Note: I searched the Apple Developer Forums as well and I couldn't find a solution so I thought I should post it here.


4. Anyways, long story short I figured out how to do it. Just create an array with the publicTimeline NSDictionary. Each object in the NSArray is an NSDictionary of statuses and using the key "text" you can retrieve the text of each tweet.






I have to finish this post later since I have midterms this week...  In the meantime you can download the project below.

Full Project Here: here

Correction: What you can do is just create an array initially.



Monday, October 17, 2011

iOS 5 Twitter Integration HelloWorld Tutorial

Edit: I just noticed that Apple provided much better sample code which can be found here: Apple Sample Code

In this tutorial we will demonstrate some new Twitter features in iOS 5.

 1. Create a new "Single View Application" called "TwitterHelloWorld".

 2. Add the Twitter Framework to your new project.



3. Go to the "TwitterHelloWorldViewController.h" file and copy and paste the following. 

4. Go to the "TwitterHelloWorldViewController.m" file and implement the following like below. The most important thing is to remember to "#include " in either (.h/.m) files. 

The Twitter framework provides a class called "TWTweetComposeViewController". To use this class you must do four things: 1) Checks for service availability 2) Creates a view controller 3) Supplies a completion handler 4) Presents Modally. 



5. Go to the MainStoryboard file and create a drag a button and connect it to the MainViewController. Connect the drag the button to the view controller and select the "presentTweetSheet:". 

6. Start the simulator and if you haven't signed into your Twitter account it will prompt you to. If you're logged in a tweet sheet will pop-up and you will be able to type text. Below is the screenshot of http://www.twitter.com/kurrytran after I posted the tweet. 











7. The sample code (which is heavily inspired by the Apple Demo) provides some other methods can you can use. If you're ever lost refer to the header files.