Hello, i'm building an app that will read rss feeds and will present them in UITableViews. I searched on google and here and ai decided to use LibXML.
When my app starts it checkes if it has a valid internet connection, and grabs an rss feed from which i extract some data and i make an uiTabBar with tableViews. after parsing the first rss feed and building the UITabBar, for each button in my uiTabBar i have a different rss feed(category). When i have a good internet connection (wifi) and even 3G my app works really good but when the internet connection suffers my app does too.
Because i parse all the feeds one after another and in the main thread the GUI just stops responding and it is a problem.
I use LibXML for parsing my feeds, i do it like this:
CXMLDocument *rssParser = [[[CXMLDocument alloc] initWithContentsOfURL:url options:0 error:nil] autorelease];
NSArray *resultDate = NULL;
resultDate = [rssParser nodesForXPath:@"//channel" error:nil];
for(CXMLElement *date in resultDate)
{
NSString *data = (NSString *)[[date childAtIndex:12] stringValue];
[self setLastBuildDate:[[self parseDate:data] copy]];
break;
}
NSArray *resultNodes = NULL;
resultNodes = [rssParser nodesForXPath:@"//item" error:nil];
for(CXMLElement *resultElement in resultNodes)
{
NSMutableDictionary *feed = [[NSMutableDictionary alloc] init];
int counter;
for(counter = 0; counter < [resultElement childCount]; counter++)
{
[feed setObject:[[resultElement childAtIndex:counter] stringValue] forKey:[[resultElement childAtIndex:counter] name]];
}
[links addObject:[feed objectForKey:@"link"]];
[feedsList addObject:[feed copy]];
[feed release];
}
[newsTable reloadData];
I tried to parse only the feed for the first button and the other ones when i push the button on the uitabbar but i can't call the functions that grab and parse the feed on -didselectitem event.
Now i was thinking of parsing them in another thread not in the main one.. can someone give me some pointers?
thank you in advance