Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create CLLocation object in objective-c

I can initialize a CLLocation object by providing latitude and longitude like below:

CLLocation *location =  [[CLLocation alloc] initWithLatitude:-43.242534 longitude:-54.93662];

How can I initialize a CLLocation object with not only latitude and longitude but also accuracy values?

like image 978
Leem.fin Avatar asked Jun 17 '16 16:06

Leem.fin


1 Answers

As per apple docs you can use the following function:

double desired_horizontal_accuracy = 200.0 // in meters
double desired_vertical_accuracy = 200.0 // in meters
[[CLLocation alloc] initWithCoordinate:CLLocationCoordinate2DMake(-43.242534,-54.93662)
                              altitude:-1
                    horizontalAccuracy:desired_horizontal_accuracy
                      verticalAccuracy:desired_vertical_accuracy
                             timestamp:[NSDate date]]

In the example, for the parameters altitude and timestamp, I put the same defaults as what the apple docs say are used on -initWithLatitude:longitude:

like image 166
Phillip Martin Avatar answered Oct 09 '22 21:10

Phillip Martin