-1

i am trying to parse the tags of xml, but i am not retrieving any value in my table view. Instead application get terminated due to exception. here is my code:

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

    if([elementName isEqualToString:@"Table"]) {
        [appDelegate.books addObject:aBook];
        [aBook release];
        aBook = nil;
    }
    else 
        [aBook setValue:currentElementValue forKey:elementName];//problem is here
        [currentElementValue release];
     currentElementValue = nil;
}

where as 'appdelegate' object of delegate class, 'Books' is mutable array in delegate class, 'aBook' is the object of 'Book' class, having property n declared strings for tag in xml.

help me out

here is my xml file:

<pre><NewDataSet>
−
<Table>
<id>1</id>
<catname>Birthday</catname>
<iid>1</iid>
<subcatname>card1</subcatname>
−
<url>
http://www.orkutpapa.com/scraps/happy-birthday-card-2-3.jpg
</url>
</Table>
−
<Table>
<id>1</id>
<catname>Birthday</catname>
<iid>2</iid>
<subcatname>card2</subcatname>
−
<url>
http://robertpattinsonwho.com/wp-content/uploads/2009/07/twilight-birthday-card.jpg
</url>
</Table>
−
<Table>
<id>1</id>
<catname>Birthday</catname>
<iid>3</iid>
<subcatname>card3</subcatname>
−
<url>
http://www.funxite.com/media/2373-birthday-card-to-wife.jpg
</url>
</Table>
−
<Table>

</pre>

exception:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key iid.' 2011-04-26 10:41:03.388 XML[631:20b] Stack: (

user720235
  • 85
  • 1
  • 11

1 Answers1

1

Try this one, it should work I was also facing same issue. It crashes in case there is integer value.

[aBook setValue:[NSString stringWithFormat:@"%@",currentElementValue] forKey:elementName];
Flexo
  • 87,323
  • 22
  • 191
  • 272
Kamleshwar
  • 2,967
  • 1
  • 25
  • 27