简体   繁体   中英

CLLocationCoordinate2D invalid initializer

I am using CLLocationCoordinate2D in to assign latitude and longitude like this

 CLLocationDegrees latitude = [somelat doubleValue];
 CLLocationDegrees longitude = [somelongi doubleValue];
 CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);

When i run this code in iPhone simulator its not showing error but wheni run the same application in ios simulator 3.2 that is the iPad simulator its showing me an "Invalid Initializer" error.

How can i resolve this...Please anybody suggest me a solution to this problem

Thanks and regards, Sankar Chandra Bose

CLLocationCoordinate2DMake is available only on iOS 4.0 and later. Do this rather,

CLLocationCoordinate2D coordinate;
coordinate.longitude = longitude;
coordinate.latitude = latitude;

CLLocationCoordinate2DMake is available only from ios 4.0. Check the reference

CLLocationCoordinate2DMake

Formats a latitude and longitude value into a coordinate data structure format.

CLLocationCoordinate2D
> CLLocationCoordinate2DMake(   
> CLLocationDegrees latitude,   
> CLLocationDegrees longitude)

Parameters

latitude

 The latitude for the new coordinate. longitude The longitude for the new coordinate. 

Return Value

A coordinate structure encompassing the latitude and longitude values.

Availability

  • Available in iOS 4.0 and later.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM