So I have an XML file and I work with it using NSXMLParser. And the needed element is
<media:thumbnail url='https://photourl.jpg' height='160' width='160'/>
I need to retrieve the url I tried this:
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"media:thumbnail"]){
NSString *string = [[attributeDict objectForKey:@"url"] stringValue];
}
But I receive SIGABRT. Can anyone help me?
Remember the value returned from attributeDict will not be retained, so you will need to retain it if you wish to use it outside the current scope.
Have you considered the case if the url attribute does not exist – in which case [attributeDict objectForKey:@”url”] will return nil.
Also, you probably do not want to use stringValue, just typecast the attribute like this: