【问题标题】:how to parse the image using NSMutableDictionary?如何使用 NSMutableDictionary 解析图像?
【发布时间】:2010-11-10 10:38:34
【问题描述】:

我需要帮助来使用字典解析图像。我可以使用字典获取文本数据,但无法在我的代码中使用字典解析相应内容的图像

   -(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];
                 }
       }

【问题讨论】:

  • 这个问题太模糊了。我们不是在这里为您阅读和编写您的代码,而是请说出具体、简洁的问题。
  • @Marcel- 我认为如果我添加代码,您可以轻松理解我的问题,那就是我添加我的部分代码。
  • 很公平,我明白了。问题在于,这段代码的全部内容还不是很清楚。什么样的形象? UIImage/NSImage?还是某种文件系统映像?您将如何“解析”图像,无论它是什么?你在解析什么样的xml?什么是“对应内容”?我认为这就是问题所在。添加一些上下文信息,我们很乐意提供帮助。
  • @marcel- 我喜欢解析 UIImage 它是 NSXMLParsing 并且链接是 brownbears.com/landing/headlines-featured?feed=rss_2.0

标签: objective-c nsxmlparser xml-parsing


【解决方案1】:

最后我找到答案小错误是我解析标签而不是 url

感谢您的帮助

【讨论】:

    猜你喜欢
    • 2014-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多