次の問題があります: TV ガイドのアプリを作成しています。インターネット上の xml ファイルからチャネルのリストを解析しています。これは私のコードです:
-(void)loadListing
{
NSURL *urlListing = [NSURL URLWithString:@"http://pik.bg/TV/bnt1/29.03.2013.xml"];
NSData *webDataListing = [NSData dataWithContentsOfURL:urlListing];
NSString *xPathQueryListing = @"//elem/title";
TFHpple *parserListing = [TFHpple hppleWithXMLData:webDataListing];
NSArray *arrayListing = [parserListing searchWithXPathQuery:xPathQueryListing];
NSMutableArray *newArrayListing = [[NSMutableArray alloc] initWithCapacity:0];
for (TFHppleElement *element in arrayListing)
{
Listing *shows = [[Listing alloc] init];
[newArrayListing addObject:shows];
shows.broadcast = [[element firstChild] content];
}
_shows = newArrayListing;
[self.tableView reloadData];
}
最初の行を見てください - 私のファイルの名前は/.../01.04.2013.xml 明日のファイルは/.../02.04.2013.xmlなどになります。現在の日付に応じて異なるファイルを解析するにはどうすればよいですか? このように: 今日は /.../01.04.2013 を解析し、明日は /.../02.04.2013 などを解析します。前もって感謝します!