i’ve got this error after parsing.
* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[NSCFString stringValue]: unrecognized selector sent to instance 0x4b68480’
Code is
-(void)parser: (NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
if([elementName isEqualToString:@"gallery"]){
}
else if ([elementName isEqualToString:@"asset"]){
NSString *str ;
str = [[attributeDict objectForKey:@"type"] stringValue]; <- HERE
NSLog(@"type = %@",str);
str = [[attributeDict objectForKey:@"thumbnail"] stringValue]; <- HERE
NSLog(@"thumbnail = %@",str);
str = [[attributeDict objectForKey:@"large"] stringValue]; <- HERE
NSLog(@"large = %@",str);
}
NSLog(@"Processing Element: %@",elementName);
}
XML tree looks like
“<“gallery …”>”
“<“asset type=”image” thumbnail=”/…” large=”/…” “>”
…
Thank you for help!
The error tells obviously
[attributeDict objectForKey:...]is returningNSStringalready. So, you do not have to callstringValueto store intostr. i.e., instead ofyou can just do