I’m essentially saving the items from RSS feeds into an array and then placing that array into another one to contain them all. For instance, I’m working on saving a bunch of educational videos by Chapter (each chapter has an RSS feed), so I’m parsing them using MWFeedParser all at once using this logic:
for (NSString *url in videosArray) {
NSURL *feedURL = [NSURL URLWithString:url];
feedParser = [[MWFeedParser alloc] initWithFeedURL:feedURL];
feedParser.delegate = self;
feedParser.feedParseType = ParseTypeFull;
feedParser.connectionType = ConnectionTypeAsynchronously;
[feedParser parse];
}
While this does the job, if the Chapter 3 RSS feed finishes parsing before Chapter 2, the content of Chapter 3 is saved in Chapter 2’s spot. While this may sound like an unnecessarily complicated explanation, my request is simply this:
Is there any way to parse one feed at a time from a list of feeds and not continue until a feed is fully parsed it’s contents are inserted into the array?
If it helps, here are 4 delegate methods that may be useful:
- (void)feedParserDidStart:(MWFeedParser *)parser {
NSLog(@"Started Parsing: %@", parser.url);
}
- (void)feedParser:(MWFeedParser *)parser didParseFeedInfo:(MWFeedInfo *)info {
NSLog(@"Parsed Feed Info: “%@”", info.title);
self.title = info.title;
}
- (void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item {
NSLog(@"Parsed Feed Item: “%@”", item.title);
if (item) [parsedItems addObject:item];
}
- (void)feedParserDidFinish:(MWFeedParser *)parser {
NSLog(@"Finished Parsing%@", (parser.stopped ? @" (Stopped)" : @""));
[courseBeingBuilt.mediaCollection addObject:parsedItems]; // Place chapter contents into Course's Chapter w/contents array
parsedItems = [[NSMutableArray alloc] init]; // Create new array for new chapter
}
Thanks guys!
Sounds like you could keep track of the index within
videosArrayin a variable (say,NSUInteger currentIndex) and use that in thefeedParserDidFinish:method to start parsing the next feed.Write the following method:
Instead of your
forloop, just:And then in
feedParserDidFinish::