UITableView and two RSS feeds
I'm trying to parse two RSS feeds at the same time using a for loop, but the thing is, when the first RSS feed is parsed completely and allocated in the table view, parsing the second feed causes the table view to be overwritten by that second feed, showing the second RSS only. Is there a way to show both the feeds? The code is below.
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if ([stories count] == 0) {
NSString * path;
path=[NSArray arrayWithObjects:@"http://www.marshillchurch.org/media/luke/feed/vodcast_video","http://www.marshillchurch.org/media/luke/feed/vodcast_audio",nil];
//[self parseXMLFileAtURL:path];
[self refresh:path];
}
cellSize = CGSizeMake([newsTable bounds].size.width, 60);
}
- (NSString *)refresh:(NSString *)path
{
for(NSString *feed in path)
{
[self parseXMLFileAtURL:feed];
// NSLog(@"the path is great:%@",feed);
}
}
- (void)parseXMLFileAtURL:(NSString *)URL
{
stories = [[NSMutableArray alloc] init];
NSURL *xmlURL = [NSURL URLWithString:URL];
rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[rssParser setDelegate:self];
[rssParser setShouldProcessNamespaces:NO];
[rssParser setShouldReportNamespacePrefixes:NO];
[rssParser setShouldResolveExternalEntities:NO];
[rssPa开发者_运维知识库rser parse];
}
You are overwriting the "stories" array every time you parse the XML (I assume that you are using the stores array in your tableview datasource). You should take a look at NSMutableArray's addObject method.
精彩评论