62 comments

  1. This is pretty solid. Looking forward to the next one.

  2. Very nice! Thanks

  3. Superb, just what i was looking for to a) understand Objective C a bit more and b) understand the twitter API – great work, keep it coming

  4. Austin in Austin

    This is exactly what I am looking for! I am writing an iPhone app that will use the Twitter API. Good stuff Brandon! kthx

  5. What Austin said above – I really enjoyed this – and I can’t wait for next version on how to parse and display the tweets! I’m looking to make a iPhone application for Twitter.

    Thanks for the information!

  6. hi brandon
    thank you very much for your working NSURLCredentials example!
    looked into a ton of pages, but your very clean and straight-forward example was very informative. i’ve been able to implement my NSURL-stuff as i wanted now.
    and yes, as macJasp told: i also learned a lot about objective-c with your walkthrough; didn’t know that delegate-thing till today.

    thanks again & best wishes from switzerland,
    manuel

  7. thanks for supporting novice programmers like me. This tutorial helped alot. Thanks from Japan.

  8. Hi Brandon,

    This is an awesome tutorial. I have been searching high and low for something like this on google. Thanks a lot man!

  9. In applicationDidFinishLaunching “tr” is allocated but never released. Wouldn’t this cause a memory leak? Also friends_timeline_callback allocates “timeline” but doesn’t release it.

  10. Very clean code! Nice.

    How hard would this be to get working on the iPhone sdk. For example, I don’t think that NSURLAuthenticationChallenge is available in the SDK…

  11. I answered my own question. It works great with the iPhone SDK.

  12. Just noticed that you define theRequest as an NSURLRequest, but you are initializing it as an NSMutableURLRequest. I think these should be consistent one way or the other. I personally prefer NSMutableURLRequest.

  13. This is a great tutorial… it’s very clear (and thanks for not making the code copy/paste-able, it really helps!)
    Can’t wait for part two.

    –Brad

  14. Verry nice!

    Is it good practice to return the request object along with the data to be able to release the request in the callback? like so:

    in TwitterRequest.m:
    [delegate performSelector:self.callback withObject:recievedData withObject:self];

    in delegate:
    - (void) friends_timeline_callback:(NSData *)data fromRequest:(TwitterRequest *)request{
    /*do stuff*/
    [request release];
    }

    • Actually, you can go ahead and release the request right after you are done calling the [tr friends_timeline]. So just do, [tr release] on the next line.

      I was just lazy. Good catch though!

  15. I’m getting a blank window when I run this. It happens even when I download the Chripie app. What do you think I’m doing wrong?

    • Hey Mike,

      You should get a blank window as we have not created the interface yet. I am almost done with the next part of the tutorial so we will start seeing some stuff.

      However, if you open up the console, you will see the XML returned from Twitter. That is what this tutorial is all about.

      To open the console in XCode:

      Click Run -> Console

      In the next tutorial, I will discuss how to parse this response from Twitter and begin creating the interface.

      Thanks for reading.

  16. Ah! Thanks.

    It was driving me crazy.

  17. Brandon,

    Do you know how to adapt this code to hit the Tweetworks api? http://www.tweetworks.com/pages/api

    I’m lost on how to use the API key.

    Full disclosure, I’m the founder of Tweetworks. I’m not a developer (I hired the firm that built the site, but they aren’t iPhone developers.) I’m trying to tinker around with the things myself for fun but getting stuck.

    • Yea, it doesn’t look like it will be too hard. Your API requires POST and we haven’t implemented yet. I’ll have the next tutorial in this series up sometime this week which should detail that.

      If you are really daring, you can check out my iPhone tutorial that I wrote here which does include POST.

  18. Cool. How about the API Key piece? The Twitter API doesn’t require a key, but Tweetworks does. That’s mainly to slow down potentially malicious apps and have some understanding where volume comes from.

    If you’d prefer to take this convo off your blog, please feel free to email me. That is if you are feeling generous with your time.

    • I don’t mind it on my blog. Prob more efficient for me than email. The API key will just get sent in the POST. It looks like your POST should look like data[key]=keyval&data[Post][body]=posttext&data[Post][sendToTwitter]=1.

      If you read the other tutorial I pointed you to, it should become apparent where this should go.

  19. Excellent. I’ll rock through the other tutorial.

    I sincerely appreciate the help. I can’t tell you how maddening it is to not know how to work on my own product.

    Users are clamoring for a Tweetworks powered iPhone app but as a self funded startup things take time.

  20. Mhike Miranda

    Very nice tutorial, learn a lot. I’ll bookmark it and looking forward to part 2.

  21. Great tutorial, Brandon. Have you considered writing one with OAuth.

  22. HI,

    I am getting this line “less than 20 seconds ago from Api” after the status..

    I want my site name there.. How to do that..
    Please help me. Thanks in advance.

  23. This is a great tutorial, but somethings wrong… on the applicationdelegat.m,, i replaced your fake info with my real twitter account, then clicked run/Console it shows up exactly the way the chearpy app, shows up, but it dosnt look like the one in the picture. Another words, i typed in correct info, and in the console, it didnt show my timeline. can you help?

  24. This application crashes in the SDK 3.1.2 working fine in 3.0 and 3.1 .
    crash over method authentication challege , please help me

  25. Excellent! I fully understand — I did the typing :) — and it was integrated and working in ~2 hours. I would suggest to others to add the following debug / trace statement until you are further along. It zeroed me in on my typing errors very quickly. Place the following two lines in connection:didReceiveData:

    NSString *s = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
    NSLog(@”%@”, s);

    Other than that, the only bugs I found were the ones I introduced :)

    I am a follower and I will “Donate” after my first full victory. Still $truggling …

  26. Thanks for the tutorial, helped me a lot on figuring out the use of http connections.

  27. Hi Brandon,

    This is exactly the kind of tutorial I was looking for. Brillinat.

    I was wondering when we will see part two?

    Regards

    Shaun

  28. Brandon,

    I had to run this a second time from scratch since my macbook took a dive and I did not have a recent enough backup. It was just as awesome the second time as the first.

    You have a great style for concise detail and you make it meaningful.

    -mobibob

  29. hey was just wondering when are you gona be doing part 2?

  30. Great Tutorial, it helped me a lot in my recent work!

  31. I also recommend mobibob suggestion!

    Cheers!
    Pierre

  32. Thanks, Dude.
    This is what I am looking for these days.
    Bookmarked your web!!

  33. trying to create simple twitter client- what code would allow for different users to login with their username and passwords?

  34. Great Code!
    I’m a newbie to study xcode to produce program for iphone and mac..

    Thanks,will follow ur instruction then

    Vit (@freoniel)
    Bangkok,Thailand

  35. Very good and excellent article. I am waiting for the part 2 for this article which contains the formatted response of the result returned by the twitter sevice

  36. maxfiresolutions

    Sir, i am a newbee on this and the iphone thing, but can you post/ tweet an image from the iphone using your code. I see that NSString is used, but is there any way to send images as tweets. I am really stuck on this one. Please forgive me for basic question. Thanks

  37. Please cite your sources, 98% of this code is lifted directly from Apple’s documentation:

    http://developer.apple.com/mac/library/DOCUMENTATION/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html

  38. @seriously – I am not claiming to have come up with the code 100%. Of course I would have had learn it from the Apple SDK.

    Using NSURLConnection is a VERY standard process that doesn’t change much from project to project. What really changes is how you interact with the data you receive from the web. I am just showing how to use it to connect to Twitter.

    So, stop being so CYNICAL and scouring the web looking for blogs where you can attempt to correct others in a sad attempt to boost your own self esteem.

  39. Alejandra Meraz

    This is THE BEST TUTORIAL EVER!! You have saved my life… and job!! Thank you!!!

  40. Thank you for the great tutorial, saved me a lot of time for sure. I was wondering if you knew how to change the “via API” to “via [name of app]” when I post?

  41. Patrick Proctor

    This was a really nice run-through of a Mac Twitter client. However, you may want to change the image in the tutorial so that each of the @synthesize tokens has a semicolon at the end. The code that you made available for download runs fine, but I kept getting a “syntax error before ‘AT_NAME’ token” error when running without the semicolons.

    Still, this is an excellent tutorial.

  42. Very Nice tutorial…Waiting for next step…how to parse it……Please post it early so that we can also feel like wow………

  43. Thank you for the great tutorial, saved me a lot of time for sure. I was wondering if you knew how to change the “via API” to “via [name of app]” when I post?

  44. Hey Bradon….when can we expect the next tutorial parsing of the response data of the series….waiting for this………Please reply me soon ……

  45. Hi,
    Could u pls tell me what is the need to register our app in twitter and also the need for oAuth process as mentioned in dev.twitter.com… Bcoz I dont see u having done any of these and when i used your code with few modications in my app, I could post a message form my app onto twitter succesfuuly…So whats the need for all those steps mentioned in dev.twitter.com???

  46. This tutorial is quite useful but you avoid to explain the important stuff. I do want to understand not to just copy your code… For instance what does the code within connectionDidFinishLaunching mean? Could you explain that?

    Cheers

  47. Hello, very nice tutorial. Could you explain a bit more on the -(void)connectionDidFinishLoading:(NSURLConnection *)connection method of the TwitterRequest? I think that the following lines:

    if(delegate && callback)
    {
    if([delegate respondsToSelector:self.callback])
    {
    [delegate performSelector:self.callback withObject:receivedData];
    }

    require a bit more explaining.

    Thanks

  48. And where is the second part?

  49. Thank you so much for the post!!! im new to iphone and i’ve been lookin all over the internet to find a tutorial to help me out, and tell me the methods used so i can corelate them and that is what this post did to me :D thank you soo soo soo much :D

Leave a comment