Warning when approaching a CLLocationCoordinate2D - how? [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm looking for a way, to get a notification/warning, whenever I'm approaching a certain location.
I'm using a locationManager for receiving new locations as-i-go, and i have an array of CLLocationCoordinate2D-objects. I want to be informed when i'm getting close to one of those objects - say 10 meters or so.
Any suggestions?
Thanks

Use CLLocation:
Create a new CLLocation Object:
- initWithLatitude:longitude:
To determine the distance use:
– distanceFromLocation:
Im not familiar with your code, but this example will push you in the right direction:
CLLocation* firstLocation = [[CLLocation alloc] initWithLatitude:53.481508 longitude:33.398438];
CLLocation* secondLocation = [[CLLocation alloc] initWithLatitude:-13.678013 longitude:-46.40625];
CLLocationDistance distance = [firstLocation distanceFromLocation:secondLocation];
if(distance < 10.00){
NSLog(#"Distance is smaller than 10 meters");
}

Related

Get coordinate based on progress on route - Mapkit - Swift [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 1 year ago.
Improve this question
Basically, I have two points, A and B that are 10 miles apart if you drive. I draw a route using driving directions between them using MapKit.
I want to find point C's latitude and longitude, which is at the point on the route 2 miles from point A. This could also work based on a percentage(ex: 20% of the route is completed between point A and B).
Hopefully, this image can explain better then I can.
Does anyone have any idea on how to do this using Swift and MapKit?
Thanks!
You may want to check out the MKRoute response you receive from the MKDirections.
An MKRoute object defines the geometry for the route—that is, it contains line segments associated with specific map coordinates.
You will find the documentation for MKRoute here:
https://developer.apple.com/documentation/mapkit/mkroute

is there a way to measure Swift's performance without building UI on iPhone with Xcode 11? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to measure performance of different swift libraries without writing UI on iPhone. There are many examples of Swift/UI examples that are normally, multi-threaded in nature. So what I want to measure is raw performance without gui overhead, if possible. And the output can we printed into the Xcode 11 console window in debugger, for example. Could you please kindly point me where I could find such sample code ? I would greatly appreciate the help.
This is an example of how to measure the time of a sum of numbers
let numbersArray = [1,2,3,4,5,6,7,8,9,1,2,3,4,5,6]
func showBenchmarkTime(title:String, operation:()->()) {
let startTime = CFAbsoluteTimeGetCurrent()
operation()
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
print("Time elapsed for \(title): \(timeElapsed) s.")
}
showBenchmarkTime(title: "sum an array of numbers") {
print(numbersArray.reduce(0, +))
}

Is there a proper way to convert a Double to a Float in Swift? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I'm trying to convert a double being retrieved from an iPhone sensor into a float. Unfortunately, I can't seem to find any resources on built in functionality to do so.
If I initialize a Float or a cast to a Float from a double like so:
let roll = (Float)(attitude!.roll)
let pitch = (Float)(attitude!.pitch)
Or
let roll = Float(attitude!.roll)
let pitch = Float(attitude!.pitch)
the original Double values still don't get converted properly.
For instance, 9.436222 and 27.895268 become 0.486864 and 0.164693 respectively. Is there a proper way to cast to a Float from a Double that preserves the larger decimal value?
guard let unwrappedAttitude = attitude else {
fatalError("attitude was nil!")
}
let roll = Float(unwrappedAttitude.roll)
let pitch = Float(unwrappedAttitude.pitch)
should be the way to go.

Convert from inches,lbs to centimeter,kg in iOS [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a problem:
My app allow user choose 2 options : Metric or Imperial.
If user select "Metric", height(cm), weight(kg).
If Select "Imperial: height(inch) and weight (lbs).
I need to change value of height from inch to centimeter and weight from lbs to kg.
Example :
user input : 70 (inch) and 120 (lbs) ==> convert to 177.8 (cm) and 54.5 (kg)
Thanks in advance.
The best example of unit convert is below link..

N different pin colors for each array of annotations.How? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
In my app i have n arrays of annotations in my app, foodannotations, gasannotations, and shoppingannotations. I want each array of annotations to show a different colored pin. I am currently using.
Already a discussion was been done regarding this. Please search question if it is already available before you ask. Thanks.
Pls refer the following links:
iPhone SDK: MapKit multiple custom annotations
Multiple Arrays of Annotations, Different Pin Color for Each Array?
Do this in viewForAnnotation:
int annType = ((YourAnnotationClass *)annotation).annotationType;
switch (annType)
{
case 0 : //Food
pinview.pinColor = MKPinAnnotationColorRed;
case 1 : //Gas
pinview.pinColor = MKPinAnnotationColorGreen;
default : //default or Shopping
pinview.pinColor = MKPinAnnotationColorPurple;
}

Resources