我正在学习Objective-C并执行一些个人项目应用程序。分析Feed时,本地保存的最佳方式是什么?
我解析一个新闻提要,并在tableview中显示,一切正常。 但每次我打开应用程序,我必须再次加载整个饲料,并再次加载所有的新闻。
我想知道,在本地存储器中保存这些消息的最佳方式是什么,每当我打开应用程序时,只需检查Feed以查看是否有新消息并补充本地存储,所以我可以仅用本地保存的消息填充tableview?
现在我使用RaptureXML通过的项目进行迭代,做这样的:
-(void)fetchRssWithURL:(NSURL*)url complete:(RSSLoaderCompleteBlock)c{
dispatch_async(kBgQueue, ^{
RXMLElement *rss = [RXMLElement elementFromURL: url];
RXMLElement* title = [[rss child:@"channel"] child:@"title"];
NSArray* items = [[rss child:@"channel"] children:@"item"];
NSMutableArray* result = [NSMutableArray arrayWithCapacity:items.count];
cachedImages = [[NSMutableArray alloc] init];
if(items) {
for (RXMLElement *e in items) {
RSSItem* item = [[RSSItem alloc] init];
item.title = [[e child:@"title"] text];
item.description = [[e child:@"description"] text];
item.link = [NSURL URLWithString: [[e child:@"link"] text]];
item.content = [[e child:@"encoded"] text];
[result addObject: item];
}
}
c([title text], result);
});
}