Subrat Padhi Subrat Padhi - 3 months ago 16
Objective-C Question

This is my code, where I have parsed the `XML` data for latitude and longitude

This is my code, where I have parsed the

XML
data for latitude and longitude.

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

if ([elementName isEqualToString:@"result"])
{
[inputArray addObject:[[NSMutableDictionary alloc] initWithDictionary:dictTempDataStorage]];

}
else if ([elementName isEqualToString:@"name"])
{
[dictTempDataStorage setObject:[NSString stringWithString:foundValue] forKey:@"name"];
}
else if ([elementName isEqualToString:@"vicinity"])
{
[dictTempDataStorage setObject:[NSString stringWithString:foundValue] forKey:@"vicinity"];
}

else if ([elementName isEqualToString:@"lat"])
{
[dictTempDataStorage setObject:[NSString stringWithString:foundValue] forKey:@"latitude"];

}

else if ([elementName isEqualToString:@"lng"])
{
[dictTempDataStorage setObject:[NSString stringWithString:foundValue] forKey:@"long"];
}
[foundValue setString:@""];


}

Answer

If you want to set the lat,long value into dictionary

else if ([elementName isEqualToString:@"lat"])
{
     NSNumber *numberLat = [NSNumber numberWithDouble:foundValue];
     NSString *strLat = [numberLat stringValue];
     [dictTempDataStorage setObject:strLat forKey:@"latitude"];
}
else if ([elementName isEqualToString:@"lng"])
{
    NSNumber *numberLong = [NSNumber numberWithDouble:foundValue];
    NSString *strLong = [numberLong stringValue];
    [dictTempDataStorage setObject:strLong forKey:@"long"];
}