1
- (void)viewDidLoad {
    [super viewDidLoad];   

    self.clm = [[CLLocationManager alloc] init];

    [_clm setDelegate:self];

    _clm.desiredAccuracy = kCLLocationAccuracyBest;

    _clm.distanceFilter = kCLDistanceFilterNone;

    [_clm requestAlwaysAuthorization];

    [_clm startUpdatingLocation];
}

- (void)locationManager:(CLLocationManager *)manager
    didUpdateLocations:(NSArray *)locations
{
    NSLog(@"%@",locations);

    CLLocation *location = [_clm location];

    NSString *string = [NSString stringWithFormat:@"%f,%f",location.coordinate.latitude,location.coordinate.longitude];

    [_nowFiled setText:string];
}

When I enabled simulate location, I can get location updated. When I disabled simulate location, I cannot get location updated.

  • How can fixed this?
  • How can I get delegate method invoked?
  • Did I miss something?
  • Maybe need time to get location?
Maciej Lach
  • 1,622
  • 3
  • 20
  • 27
  • Please clarify your question. – Maciej Lach Aug 18 '15 at 09:52
  • I used Xcode to debug CLLocation project on iPhone 6+,but cannot get the delegate method invoked,when I enable "simulate Location" of xcoce,the delegate method was invoked,but after i disable "simulate Location",the delegate method become silence. – johnny_mess Aug 18 '15 at 10:13

2 Answers2

0

Occasionally(Not always),it would invoke error: Operation could not be completed(KCLErrorDomain error 0)

I found the solution at Location Manager Error : (KCLErrorDomain error 0).

Scheme->Edit Scheme->Run->check out(Not check)"Allow Location Simulation".

And the problem is solved.

Community
  • 1
  • 1
0

When you attach a real device for debugging:

  • The device will inherit the debug settings for location under Debug > Simulate Location.
  • If you set this to "Don't Simulate Location" then the attached device will use it's real location as returned by the GPS/WiFi (if the device is capable).
  • If you choose any other setting (location), the attached device will NOT use it's real location rather it will simulate the location chosen.

If you disable Core Location "Allow Location Simulation" under Product > Schema > Edit Schema you will NOT be able to simulate locations in debut however, if the attached device support location, the real device location will be used.

rmp
  • 3,503
  • 1
  • 17
  • 26