RSS Reader for iPhone

If you have read my blog description just below the blog title you would realize where I am hanging out these days. [object message] is a way to send a message (method) to an object in objective C. I have been working on iphone sdk for a week, going through the online reference library at http://developer.apple.com and stumbling over blogs explaining some code. Let me tell you, this week was full of new learning in terms of a language, a framework and frustrations! Here are a few snapshots of an RSS reader I built for the iphone.

Picture 8 Picture 1Picture 2 Picture 3

Picture 4 Picture 6 Picture 7 Picture 5

Before I delve into the major discussion about the app, let me frustrate those guys who are just entering the world of iphone development. In the XCode editor, which is used for writiing apps on Mac, there are 2 options to debug an application. One is in the iPhone Simulator whose snapshots are seen above. This is available to everyone who installs the iphone sdk. Other option is directly on the device, iPhone or iTouch. Hold On… You can debug and install apps created on an iphone ONLY IF YOU ARE A REGISTERED IPHONE DEVELOPER PAYING $99 TO APPLE EVERY YEAR. smirks!!! The account used for downloading the sdk is not the one used here. You will notice this when you would try to build the application and install it on your iPhone/iTouch and get an error saying something like Unable to Verify device 0X160434fuc@##$#shi#$#$ :), I learnt the hard way, if you want to know more about this mess read the blog post by Ralf Rottman here.

Anyways, if you are done pulling your hair off, here are some functionalities of the Reader –:

- Add and Remove a feed. The feed data gets stored in a property list which are basically a nice way to store application data.

- A refresh button causes s refresh of all blogs and displays the first post of each of them on the first screen.

- Read the post in a browser window itself. This is done using the UIWebVIew class which allows to open a url in a Safari browser window.

Another word of caution for guys trying to build something which would need to parse XML. The NSXML library which is the one used to parse XML in Mac applications does not work on the iphone/itouch but works on the simulator! I have not personally checked this but there are lots of blogs talking about it. So instead I used TouchXML which is an open source library on http://code.google.com/p/touchcode/. More information about how to use the parser in this library is well explained on Dean’s blog http://dblog.com.au/general/iphone-sdk-tutorial-building-an-advanced-rss-reader-using-touchxml-part-1/. Some good references for beginners are here –:

1) Aaron Hillegas book on Cocoa Programming for MacOSX. – This is an awesome book for guys like me who have been working on Windows platform for a while and want to shift gears for some time and get some Cocoa! The book really helps a lot to make us understand several aspects of the Cocoa framework and Objective C. For ebook lovers, there is an online version of this book somewhere in the cloud, I have it, just search for it.

2) http://developer.apple.com Apple has provided extensive coding how to’s and other references which I found helpful.

3) http://theappleblog.com has good tutorials.

The iPhone sdk uses the MVC pattern, so its a good idea to follow that while building our apps.Create a separate View and View Controller for each different screen you wish to see in your app. If you righr click on the project in the left had side tree view panel of XCode you would see an option to add a Group. Click that and add a UIView and a UIViewController in it. This way you just have a clean separaion of all the files. When you create a project like a Utility Application Project or a Navigation project etc you would see some groups already created. So in short, an iPhone/iTouch app at one time displays a single View added as a subview to the main window. To change the screen, remove the view already there and add a new one. Thats how any application on iPhone/iTouch works.Since I use property lists to store the feed data, it becomes really easy to read and write to them. But do not use these lists if you expect the data to grow too much. Property lists are good for few hundred bytes. They are just XML format files which can be added to a project.

I will be posting some code snippets in my subsequent posts since its the code that matters! By this time in a week time or so I have pretty decent understanding on how the View Controllers, Views and other elements of an iPhone application interact with each other. Ill be talking a bit about using UINavigationControllers, sharing data among views and other important things which are used more often. Please let me know if you have any questions, Ill be glad to help.

Happy Programming!

Abhang Rane


9 comments :

Reader's Comments

  1. Hi,

    Nice posting buddy, I am working on microsoft platform with C#.

    I am very much curious about these apps. I have one interesting project to execute, if you are interested do let me know.

    Thanks
    Anil
    +91 9833066338
    anilmane123@gmail.com

    ReplyDelete
  2. Hi Anil - I've followed the tutorial at dblog and got TouchXML to work with the url used in that tutorial but can't get it to work with blogspot feeds. Is it something to do with the version of xml that Google's free blogger tool uses? Do I need a precompile file?

    Thanking you in advance. Gary - gazmac2@me.com

    ReplyDelete
  3. Hey gazmac,
    My name is Abhang. Anil is some guy who left a comment :). Anyways, what error are you getting. Are the feeds you using Atom or RSS. May be that might clear some doubt. Just guessing though.

    ReplyDelete
  4. Sorry Abhang of doing you the discourtesy of getting your name wrong! It's an Atom feed from my blog, gazasolidarity - see link - I'm having trouble with. I'm writing this in bed on my iPhone but will post more detail tomorrow if that's ok. And hey thanks for your time. Gary (in London) - I guess it must be early morning in India.

    ReplyDelete
  5. No probs. Ill try to add your blog in my application to see what error I get.

    ReplyDelete
  6. Hi Abhang - I don't get any errors apart from one warning - 'setText is deprecated...' in the cellForRowAtIndexPath method which is an error that I get with blog feeds that do parse correctly so I don't think that's the issue. The code compiles but the table cells don't get populated.

    [cell setText:[[blogEntries objectAtIndex: blogEntryIndex] objectForKey:@"title";

    warning: setText is deprecated...

    return cell;

    I hope you will accept a small payment from me if you are able to provide solution. Do you have a PayPal account? gary

    ReplyDelete
  7. No thanks. Although a dumb comment, but I see you are missing 2 square brackets in the line of code you have given. Also are you setting the number of rows in the numberofRowsinSection function.

    ReplyDelete
  8. Hello,

    Where can i find this code source ?

    Thanks for the answers

    ReplyDelete
  9. Yes, This will help communicate with your developer and make things run smoother.

    iphone developer

    ReplyDelete