Disable location service in iPhone simulator?

这一生的挚爱 提交于 2019-12-05 04:14:45

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

You can disable the location services in 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!

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

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

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

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

Disconnect the computer from internet connection. How to.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!