[英]How to convert NSMutableArray to CLLocationCoordinate2D
I have NSMutableArray: 我有NSMutableArray:
userCoordinates = [[d objectForKey:@"geo"] objectForKey:@"coordinates"];
NSLog(@"%@",userCoordinates);
NSLog shows: NSLog显示:
(
"19.365367",
"-99.159887"
)
Then I need to convert this array to CllocationCoordinate2D to use it for create annotation. 然后,我需要将此数组转换为CllocationCoordinate2D,以将其用于创建注释。 Sorry my english.
对不起,我的英语。 Thanks.
谢谢。
It seems that your array contains two NSString
objects - to convert them to the appropriate floating-point numbers, use the doubleValue
method of NSString
: 看来您的数组包含两个
NSString
对象-要将它们转换为适当的浮点数,请使用NSString
的doubleValue
方法:
double lat = [(NSString *)[userCoordinates objectAtIndex:0] doubleValue];
double lon = [(NSString *)[userCoordinates objectAtIndex:1] doubleValue];
CLLocationCoordinate2D coords = (CLLocationCoordinate2D){ lat, lon };
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.