Leem.fin
Leem.fin

Reputation: 42602

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?

Upvotes: 5

Views: 4504

Answers (1)

Phillip Martin
Phillip Martin

Reputation: 1960

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:

Upvotes: 6

Related Questions