// RootViewController.m
- (NSString *)getFirstImage:(NSString *)htmlString{
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString: htmlString];
// find start of tag
[theScanner scanUpToString: @"<img src=\"" intoString: NULL];
if ([theScanner isAtEnd] == NO) {
NSInteger newLoc = [theScanner scanLocation] + 10;
[theScanner setScanLocation: newLoc];
// find end of tag
[theScanner scanUpToString: @"\"" intoString: &text];
}
return text;
}
(void)feedParser:(MWFeedParser *)parser didParseFeedItem:(MWFeedItem *)item {
NSLog(@"Parsed Feed Item: %@", item.title);
NSString* str_imageUrl = [self getFirstImage:item.summary];
item.firstImg = [NSData dataWithContentsOfURL:[NSURL URLWithString:str_imageUrl]];
if (item) [parsedItems addObject:item];
}