Search code examples
iphoneobjective-cstringcllocation

String to CLLocation latitude and Longitude


I have two strings representing latitude and longitude like: "-56.6462520", and i want to assign then to a CLLocation object to compare to my current location.I tried the following code but i get errors only:

CLLocation * LocationAtual = [[CLLocation alloc]init];
LocationAtual.coordinate.latitude = @"-56.6462520";
LocationAtual.coordinate.longitude = @"-36.6462520";

and then compare the object with my actual location latitude and longitude. Any suggestions?


Solution

  • I think you need to:

    LocationAtual.coordinate.latitude = [@"-56.6462520" floatValue];
    LocationAtual.coordinate.longitude = [@"-36.6462520" floatValue];