将'NSString * __ strong'传递给不兼容类型'CLLocationDegrees'(又名'double')的参数

时间:2014-02-09 16:08:44

标签: ios objective-c google-maps

我尝试从Google Maps SDK中检索纬度和经度值,我正在使用它:

NSString *lati = [end_loc objectForKey:@"lat"];
NSString *longi = [end_loc objectForKey:@"lng"];
marker.position = CLLocationCoordinate2DMake(lati, longi);

但是在 marker.position 的行中我收到此错误:

Passing 'NSString *__strong' to parameter of incompatible type 'CLLocationDegrees' (aka 'double')

关于如何解决它的任何想法?

1 个答案:

答案 0 :(得分:7)

那是因为CLLocationCoordinate2DMake希望CLLocationDegrees作为一种参数,并且你传递NSStrings(或者在end_lok中传递key lat / lon的内容)。

您可以尝试解决此问题:

NSString *lati = [end_loc objectForKey:@"lat"];
NSString *longi = [end_loc objectForKey:@"lng"];
marker.position = CLLocationCoordinate2DMake([lati doubleValue], [longi doubleValue]);