所以我正在为 iPhone 制作一个非常简单的 RSS 阅读器,但是当我启动它时,没有任何项目出现在我正在使用的提要中。它适用于其他人,但不适用于 feeds.feedburner/ParadiseBeats feedburner 是否使用与其他 feed 不同的系统?我第一次使用的提要是 technobuffalo.com/feeds,它可以很好地按行显示故事。
以下是相关代码:
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if ([stories count] == 0) {
NSString *path = @"http://feeds.feedburner.com/ParadiseBeats";
[self parseXMLFileAtURL:path];
}
}
和元素解析...
-(void)parser:(NSXMLParser *) parser didStartElement:(NSString *) elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *__strong)qName attributes:(NSDictionary *__strong)attributeDict {
currentElement = [elementName copy];
if([elementName isEqualToString:@"item"]){
//clear out story item caches...
item = [[NSMutableDictionary alloc] init];
currentTitle = [[NSMutableString alloc] init];
currentDate = [[NSMutableString alloc] init];
currentSummary = [[NSMutableString alloc] init];
currentLink = [[NSMutableString alloc] init];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *__strong)elementName namespaceURI:(NSString *__strong)namespaceURI qualifiedName:(NSString *__strong)qName {
if ([elementName isEqualToString:@"item"]) {
[item setObject:currentTitle forKey:@"title"];
[item setObject:currentLink forKey:@"link"];
[item setObject:currentSummary forKey:@"summary"];
[item setObject:currentDate forKey:@"date"];
[stories addObject:[item copy]];
NSLog(@"adding story: %@", currentTitle);
}
}