[ACCEPTED]-Disable location service in iPhone simulator?-core-location

Accepted answer
Score: 11

You can disable the location services in 1 the simulator;

  1. Run your app through xcode so the simulator opens
  2. Stop the app via xcode (this should leave the simulator open)
  3. Open the Settings app in the simulator window
  4. Privacy > Location Services. Disable Location Services
  5. Run your app again, location services should be disabled

Hope it helps!

Score: 0

**Disregard this. This works around the 5 MapKit. Check comments below.

Disconnect 4 the computer from internet connection. How to.

EDIT: You 3 can test the code from this site that can be downloaded 2 here

With AirPort on, you get the map. With the 1 AirPort off you get a blank squared view.

Score: 0

To my knowledge, you can't disable the location 9 service on the simulator.

The approach that 8 I normally use when using the location service 7 is to build a simple wrapper class arround 6 NSLocation tailored to the needs of my application.

In 5 this wrapper, you could easily pretend that 4 the service is not working in the simulator. For 3 example, it could have a "isEnabled" method 2 that returns false on the simulator with 1 a compiler define like (#if TARGET_ IPHONE_SIMULATOR)

Score: 0

As a workaround you can try to simulate 4 update location failure by constructing 3 NSError object with appropriate values and 2 calling corresponding CLLocationManager 1 delegate didFailWithError: method manually.

More Related questions