19

We're told, via Apple's docs on startMonitoringSignificantLocationChanges that the following behavior can be expected by an application using the signification change API:

If you start this service and your application is subsequently terminated, the system automatically relaunches the application into the background if a new event arrives. In such a case, the options dictionary passed to the locationManager:didUpdateLocations: method of your application delegate contains the key UIApplicationLaunchOptionsLocationKey to indicate that your application was launched because of a location event. Upon relaunch, you must still configure a location manager object and call this method to continue receiving location events. When you restart location services, the current event is delivered to your delegate immediately. In addition, the location property of your location manager object is populated with the most recent location object even before you start location services.

Source: Apple Docs

My question is, how would I go about debugging and/or testing this? As soon as I terminate the app I have no idea what's happening (i.e. debugging session gets killed with app). When will I know when or if iOS has launched my app in the background w/ the launchOption key of UIApplicationLaunchOptionsLocationKey set? More importantly than that, how do I know whether or not the block of code that gets executed is functioning properly? How can I test this scenario rapidly without having to drive around after terminating my app hoping the code I wrote magically works? Any help much appreciate!!

4

1 回答 1

29

使用 Xcode 的 Debug > Attach to Process > By Process Identifier (PID) or Name... 菜单:您可以提供进程的名称,然后 Xcode 将等待它启动以附加并启动调试会话。

于 2013-11-07T23:16:57.643 回答