1

In my app I have created a UITableView which retrieves the XML of the Apple hot news rss feed.. It takes the XML data and I code it so each cell has one of the posts name and if you select it it pushes to a UIViewController with a web view displaying that article. What I want to do is I want to sort the articles (cells in this case) into different categories like:

iPad iPhone Steve Jobs Music

and so on...

I am not so sure how I can present this, how can I edit the UITableView so it can sort itself and put labels in the middle and so on I think you get the point. That is my uncertainty.

I have an approach (a not very reliable way though) of categorizing them, for example in the case of iPhone I will find the cells title (which comes from the RSSItem) and see if it has the substring of iPhone:

if ([[[cell textLabel] text] rangeOfString:@"iPhone"].location != NSNotFound)
{
    NSLog(@"Found an iPhone category");
}

I know this is not reliable and involves a not very tedious/long/trial and error not logical method. So I have a SMALL IDEA on how to get this CATEGORY formed. But how to present it? Help on these two things: category and presentation would be strongly appreciated! Thank you!

WrightsCS
  • 50,551
  • 22
  • 134
  • 186
user973985
  • 291
  • 2
  • 7
  • 14

1 Answers1

0

For the presentation, you can use a grouped UITableView (use UITableViewStyleGrouped in the UITableView initWithStyle: method). Then you can use a couple of methods called numberOfRowsInSection: and titleForHeaderInSection: to create separate groups in the table, one per category. Here's a tutorial I picked at random.

Getting the categories is definitely trickier. I took a quick look at that RSS feed and there's nothing in there that's going to help you. You'd need to do some sort of semantic analysis on the text to try to grab keywords out. Here's a stack overflow question that might help get you started. Good luck!

Community
  • 1
  • 1
sgress454
  • 24,870
  • 4
  • 74
  • 92