I am facing a strange problem. I am using
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray *)locations
to get device location. It is working fine on simulator (iOS 6 and iOS 7)
and iPhone 4S running iOS 6.1.3
. It is also working fine when I connect iPhone 4 running iOS 7
to system and install the app but as soon as I unplug the device and re-run the app, this method doesn't get called and I don't get the location. How can I overcome this issue?
Asked
Active
Viewed 2,308 times
1

Ankur Arya
- 4,693
- 5
- 29
- 50
1 Answers
-1
How did you setup you location Manager?
Do you have in your interface:
@interface ViewController : UIViewController <CLLocationManagerDelegate> {
@property (strong, nonatomic) CLLocationManager *locationManager;
}
Then in implementation in viewDidLoad:
// setup location manager
if ([CLLocationManager locationServicesEnabled]) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
_locationManager.delegate = self;
[_locationManager startUpdatingLocation];
}
And you need to implement the delegate:
locationManager:didUpdateLocations:
Be careful: In IOS 7
locationManager:didUpdateToLocation:fromLocation
is deprecated. Apple link to CLLocationManagerDelegate

y0gie007
- 727
- 1
- 7
- 11
-
`headingAvailable` is deprecated since `iOS 4` and I'm using `locationManager:didUpdateLocations:` – Ankur Arya Dec 17 '13 at 10:12
-
a..sorry. headingAvailable doesn't fit in (copy paste mistake). But anyways. headingAvailable property was deprecated. This is a call to recommended +(BOOL)headingAvailable (i changed it to locationServicesEnabled). Interesting that it does't work. Have you tried changing to _locationbManager.distanceFilter = kCLDistanceFilterNone; ? That should notify delegate of all movements. – y0gie007 Dec 17 '13 at 10:42
-
I've exactly the same code as yours apart from the `if` condition. – Ankur Arya Dec 17 '13 at 11:29
-
I've created a simple project and it works for me (iPhone 5, iOS 7.0.4) as well on the simulators: git@github.com:rendulic/CLLocationTest.git – y0gie007 Dec 19 '13 at 10:29
-
Thanks for your time, your code is working fine and the strange thing is that my code is also working today, tho I didn't change anything whatsoever – Ankur Arya Dec 19 '13 at 10:46
-
No problem. I've noticed some problems in simulators when geo location is in question. Not yet on a device. Anyhow. Its working :) – y0gie007 Dec 19 '13 at 11:10
-
I'm marking your answer as correct until someone comes up with more precise answer to this problem. – Ankur Arya Dec 19 '13 at 11:29