私は単純なRSSリーダーを持っています。ストーリーがダウンロードされ、UITableViewに入れられ、それをクリックすると、各ストーリーがUIWebViewに読み込まれます。それは素晴らしい作品です。さて、私はあなたのYouTubeアプリに表示されるように、左側に画像を組み込みたいと思います。しかし、私のアプリはRSSフィードからプルするので、行Xは行Xに明示的に指定することはできません。なぜなら、行Xは明日の行Yになり、物事が乱れるからです。私は現在YouTube RSS feedから引っ張っていて、ビデオタイトル、説明、出版日を得ることができますが、フィードの各エントリの他に小さなサムネイルを引っ張る方法については固まっています。iPhone RSSサムネイル
私はコーディング初心者です(これはHello Worldアプリケーション以外の最初のアプリケーションです)。私は自分の知識が不足しているので、とても不満を感じています。
ありがとうございます!
ところで、ここではいくつかのサンプルコードです:
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
//NSLog(@"found this element: %@", elementName);
if (currentElement) {
[currentElement release];
currentElement = nil;
}
currentElement = [elementName copy];
if ([elementName isEqualToString:@"item"]) {
// clear out our 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 *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
//NSLog(@"ended element: %@", elementName);
if ([elementName isEqualToString:@"item"]) {
// save values to an item, then store that item into the array...
[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);
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
//NSLog(@"found characters: %@", string);
// save the characters for the current item...
if ([currentElement isEqualToString:@"title"]) {
[currentTitle appendString:string];
} else if ([currentElement isEqualToString:@"link"]) {
[currentLink appendString:string];
} else if ([currentElement isEqualToString:@"description"]) {
[currentSummary appendString:string];
} else if ([currentElement isEqualToString:@"pubDate"]) {
[currentDate appendString:string];
}
}
Hmm。私が見ている最も簡単な方法は、それが他のすべてのコードがどのようにセットアップされているかのために、parserDidStartでattributeDictを使用することです。誰でもメディアのURL属性(サムネイル)を抽出するコードを教えてもらえますか? Devドキュメント:http://preview.tinyurl.com/cmhzch YouTube API:http://preview.tinyurl.com/az7tek –