core-location

How do I pass params on timer selector [duplicate]

我的梦境 提交于 2019-11-28 12:42:30
This question already has an answer here: Passing parameters to the method called by a NSTimer 6 answers func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let mostRecentLocation = locations.last else { return } print(mostRecentLocation.coordinate.latitude) print(mostRecentLocation.coordinate.longitude) Timer.scheduledTimer(timeInterval: 60.0, target: self, selector: #selector(StartTestVC.sendDataToServer), userInfo: nil, repeats: true) } func sendDataToServer (latitude: Double, longitude: Double) { SFUserManager.shared.uploadPULocation

How Can I Get Current Location on iOS? [duplicate]

♀尐吖头ヾ 提交于 2019-11-28 11:48:38
问题 This question already has answers here : how to get the current location position in map on iphone (2 answers) Closed 6 years ago . I can't get current location. When I launch my app in different place, App can get last location. But I don't want to last location. If you close the app and restart it, now app can get current location. How can I get current location even if it is first launch of application? - (void)viewDidLoad { [super viewDidLoad]; [locationManager startUpdatingLocation];

How can I tell if an iOS device has a GPS?

时间秒杀一切 提交于 2019-11-28 11:02:37
For an iPad, or iPod touch, is there a way to find out if the device has GPS? Extra Credit: What if the iPad itself does not, but it is connected to a third-party GPS unit? Can I determine this? For iOS 6 or higher, you might want to try + (BOOL)[CLLocationManager deferredLocationUpdatesAvailable] According to the documentation : Deferred location updates require the presence of GPS hardware and may not be supported on all iOS devices. fbrozovic Apple does not provide a function to directly query the device if it has GPS capabilities or not. There are two possible solutions to your problem:

iOS7 Core Location not updating

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 11:01:56
I have a very simple app example that initialises and updates the users location.. On device it successfully throws another callback location every second or so however on device (iPhone running iOS7) is calls the method once and then mysteriously stops... //Setup Location Manager in ViewDidLoad locationManager = [[CLLocationManager alloc] init]; [locationManager setDistanceFilter:kCLDistanceFilterNone]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager setDelegate:self]; [locationManager startUpdatingLocation]; -(void)locationManager:(CLLocationManager *)manager

why self.locationManager stopUpdatingLocation doesn't stop location update

牧云@^-^@ 提交于 2019-11-28 10:44:20
Problem : It seems I can't stop Core Location from sending updates to my app / tracking. What am I doing : In my viewWillAppear I call self.locationManager and pass it to a method to show user's location on the map (an instance of MKMapView ). The getter is overridden to check for availability of the serive, to see whether its authorized. If so, it allocs/inits and startMonitoringSignificantLocationChanges and returns . In viewDidDisappear , I call [self.locationManager stopUpdatingLocation] . But still I can see the location icon in the status bar. Even when I terminate the app by double

kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder

时间秒杀一切 提交于 2019-11-28 10:43:21
I have a search bar in my application that the user can type an address into, and it will come up with the geocoded result. The result updates as the user types, according to the following code: - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { ... if (self.geocoder.geocoding) [self.geocoder cancelGeocode]; [self.geocoder geocodeAddressString:searchText completionHandler:^(NSArray *placemarks, NSError *error) { if (error != nil) { NSLog(@"ERROR during geocode: %@", error.description); return; } //update the view }]; } This works for the first few characters the

Finding distance between CLLocationCoordinate2D points

情到浓时终转凉″ 提交于 2019-11-28 09:36:30
I know from documentation we can find distance between two CLLocation points using the function, distanceFromLocation: . But my problem is I dont have CLLocation data type with me, I have the CLLocationCoordinate2D points. So how can I find distance between two CLLocationCoordinate2D points. I have seen the post post but not helpful for me. Apurv You should create an object of CLLocation using, - (id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude; Then, you should be able to calculate the distance using [location1 distanceFromLocation:location2]; If it is

iPhone CoreLocation: How to get the most accurate speed

微笑、不失礼 提交于 2019-11-28 09:26:41
I'm experimenting with adding the GPS functionality to my iPhone app. It's a workout app that will be used while walking or running. So what I want to use GPS for is to show the speed that the person is moving in Mph and minute/mile. How should I configure the CLLocationManager so I get the best possible results? What should I set desiredAccuracy and distanceFilter? I've tried with: distanceFilter = 10 and desiredAccuracy = kCLLocationAccuracyNearestTenMeters and reading CLLocation.speed property Testing while driving around in my car the accuracy seems good compared to the car speedometer

iOS 6 and Location Services not working

杀马特。学长 韩版系。学妹 提交于 2019-11-28 08:43:40
I've updated my iOS SDK to version 6. After that I've compiled my app (works fine in iOS 4 & iOS 5 ) but now the location services doesn't work. My delegate isn't receiving any update and the upper location arrow is not appearing... I'm starting the service as the usual way: [locationManager startUpdatingLocation]; My project is non ARC. What is happening? This is driving me crazy... Thanks in advance. Make sure you have a CFBundleDisplayName in your project's .plist file. Adding that key fixed it for me. Just set the property pausesLocationUpdatesAutomatically of Location Manager to NO . This

CLLocationManager authorization issue iOS 8

笑着哭i 提交于 2019-11-28 08:22:10
I am working on a piece of Swift code for iOS 8. I am trying to do something which involves location, and so i have implemented the following in my swift view controller file: let locationManger:CLLocationManager = CLLocationManager() var speedReceived:Double = 0 override func viewDidLoad() { super.viewDidLoad() locationManger.delegate = self locationManger.desiredAccuracy = kCLLocationAccuracyBest let authstate = CLLocationManager.authorizationStatus() if(authstate == CLAuthorizationStatus.NotDetermined){ println("Not Authorised") locationManger.requestWhenInUseAuthorization() } // Do any