我需要帮助才能使用字典解析图像。我可以使用字典获取文本数据,但不能使用字典解析相应内容的图像,这里是我的代码
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
currentElement = [elementName copy];
if ([elementName isEqualToString:@"title"]) {
item = [[NSMutableDictionary alloc] init];
ktitle = [[NSMutableString alloc] init];
kpubdate = [[NSMutableString alloc] init];
kitem = [[NSMutableString alloc] init];
//kmedia = [[UIImageView alloc] init];
klink = [[NSMutableString alloc] init];
kdescription = [[NSMutableString alloc] init];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ([elementName isEqualToString:@"title"]) {
[item setObject:ktitle forKey:@"title"];
[item setObject:klink forKey:@"link"];
[item setObject:kdescription forKey:@"description"];
[item setObject:kpubdate forKey:@"pubDate"];
//kmedia = [[UIImageView alloc] initWithImage:[UIImage keyPathsForValuesAffectingValueForKey:@"media:content"]];
//[item setObject:kmedia forKey:@"media:content"];
[arrayList addObject:[item copy]];
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if([currentElement isEqualToString:@"title"]){
[ktitle appendString:string];
}
else if ([currentElement isEqualToString:@"link"]) {
[klink appendString:string];
}
else if([currentElement isEqualToString:@"description"]){
[kdescription appendString:string];
}
}
答案 0 :(得分:0)
最后我发现答案小错误是我解析标签而不是网址
感谢您的帮助