I am new in location services. I have used startMonitoringSignificantLocationChanges
and (void)locationManager:(CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
method but it is not getting called as I change location value. I want to fetch location value whenever user change its location.How should i achieve this? Please help me to resolve. Thanks in advance.
Asked
Active
Viewed 76 times
-1

Zalak Patel
- 1,937
- 3
- 26
- 44
-
have you assigned the CLLocationManagerDelegate? – Dheeraj Singh Mar 02 '15 at 11:34
-
@DheerajSingh Yes i have used myLocationManager.delegate = self; and assigned delegate to it. – Zalak Patel Mar 02 '15 at 12:39
-
are u using ios8? and could u show ur code – Dheeraj Singh Mar 02 '15 at 12:55
-
@DheerajSingh No ios 7 and i know for ios 8 we need to use "requestWhenInUseAuthorization" and i have done that. – Zalak Patel Mar 02 '15 at 13:01
2 Answers
0
You need to implement "didUpdateLocations" delegate method . Here is sample
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
NSLog(@"locations : %@",locations.description);
CLLocation *currentLocation = [locations lastObject];
NSLog(@"current location : %f %f",currentLocation.coordinate.latitude,currentLocation.coordinate.longitude);
}

user4261201
- 2,324
- 19
- 26
-
Please find my updated question and yes i have tried this method as well but it is not working. – Zalak Patel Mar 02 '15 at 11:33
-
didUpdateToLocation method is deprecated. If locationManager:didUpdateLocations: is implemented, this method will not be called. Once check it – user4261201 Mar 02 '15 at 11:40
-
I am using your updateLocation method then it is not getting called . Why it is happening so? – Zalak Patel Mar 02 '15 at 12:38
0
In iOS 8 you need to do two extra things to get location working: 1. add one or both of the following keys to your Info.plist file:
NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription
Next you need to request authorization for the corresponding location method, WhenInUse or Background. Use one of these calls:
[self.locationManager requestWhenInUseAuthorization];
[self.locationManager requestAlwaysAuthorization];
For details refer following link. http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/

Mike Clark
- 1,860
- 14
- 21