Simple RSS reader and parse them display into UITableview

With this I’m assuming you have a bit of familiarity with the iPhone SDK.We’re going to build an RSS feed reader for a simple feed.Let’s get started

step 1: Open Xcode and choose the “File” menu, in which you’ll click the “New Project…” item.

step 2: Click “Application” under “iPhone OS” in the list at left.

step 3: On the right, choose “Single view Application”. Then click the “Choose…” button. You’ll be prompted to pick a name and location. Type in the name “TAB RSS reader”.

step 4: Save it wherever you wish.

Click once on “RootViewController.h” in the list, and see the code on the right. Make it look like this:

That’s the declaration file, where we’re telling the compiler what to expect when it runs through the controller logic. Here’s where the real work happens… Open “RootViewController.m“.

Following methods are use for the UITableView controller

 


Following methods use for the parsing the data.

 


Grab the souce code here.

16 thoughts on “Simple RSS reader and parse them display into UITableview

    • [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
      UIApplication *app = [UIApplication sharedApplication];
      if ([app canOpenURL:[NSURL URLWithString:@"http://www.google.com"]])
      {
      [app openURL:[NSURL URLWithString:@"http://www.google.com"]];
      return;
      } else {
      NSLog(@”Can’t open URL %@”, @”http://www.google.com”);
      }

      This code is working in my xcode if you want to get demo then pls tell 2 me regarding the open url into browser

  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *MyIdentifier = @”MyIdentifier”;

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:MyIdentifier];

    }

    // Set up the cell
    int storyIndex = [indexPath indexAtPosition: [indexPath length] – 1];
    cell.textLabel.text=[[stories objectAtIndex: storyIndex] objectForKey: @”title”];

    return cell;

    }
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic

    int storyIndex = [indexPath indexAtPosition: [indexPath length] – 1];

    NSString * storyLink = [[stories objectAtIndex: storyIndex] objectForKey: @”link”];
    NSLog(@”adding story: %@”, stories);
    // clean up the link – get rid of spaces, returns, and tabs…
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSLog(@”Opening URL! ‘%@’”, storyLink);
    NSLog(@”link: %@”, storyLink);
    if ( ![storyLink hasPrefix:@"http://"] ) {
    NSString* oldLink = storyLink;
    storyLink = [@"http://" stringByAppendingString:oldLink];
    }

    // open in Safari
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];
    UIApplication *app = [UIApplication sharedApplication];
    if ([app canOpenURL:[NSURL URLWithString:storyLink]])
    {

    NSLog(@”Opening URL! ‘%@’”, storyLink);
    [app openURL:[NSURL URLWithString:storyLink]];
    return;
    } else {
    NSLog(@”Can’t open URL ‘%@’”, storyLink);
    }

    }
    link is not opening dear Neon Samuel.

  2. Bro when user click on table cell then link is open
    this code is not work in tab base view. did i wrong something .. ?

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic

    int storyIndex = [indexPath indexAtPosition: [indexPath length] – 1];

    NSString * storyLink = [[stories objectAtIndex: storyIndex] objectForKey: @”link”];
    NSLog(@”adding story: %@”, stories);
    // clean up the link – get rid of spaces, returns, and tabs…
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@"\n" withString:@""];
    storyLink = [storyLink stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSLog(@”Opening URL! ‘%@’”, storyLink);
    NSLog(@”link: %@”, storyLink);
    if ( ![storyLink hasPrefix:@"http://"] ) {
    NSString* oldLink = storyLink;
    storyLink = [@"http://" stringByAppendingString:oldLink];
    }

    // open in Safari
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:storyLink]];
    UIApplication *app = [UIApplication sharedApplication];
    if ([app canOpenURL:[NSURL URLWithString:storyLink]])
    {

    NSLog(@”Opening URL! ‘%@’”, storyLink);
    [app openURL:[NSURL URLWithString:storyLink]];
    return;
    } else {
    NSLog(@”Can’t open URL ‘%@’”, storyLink);
    }

    Thanks 4 help

  3. Hi,

    This is a great tutorial. I just have one question, the RSS feed I am loading also has images in each feed. How can I change “cell.imageView” to download the RSS feed images and show them in each cell?

    Thanks,
    Dan

Leave a message