Note that there are some explanatory texts on larger screens.

plurals
  1. POstopUodatingLocation in appDelegate
    primarykey
    data
    text
    <p>I'm using location services in my app. When the user tapped the startbutton it has to run also in the background. When the user dismisses the app without tapping the startbutton location services has to be stopped. I have to start in when loading the app thus initialzing locationservives when tapping the startbutton is not an option.</p> <p>I'm tryiing this in my appDelegate.m:</p> <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application { if([[NSUserDefaults standardUserDefaults] objectForKey:@"appRunning"] == nil) { [location stopUpdatingLocation]; [[NSUserDefaults standardUserDefaults] synchronize]; NSLog(@"%@", [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]); } } </code></pre> <p>in both applicationWillResignActive and applicationDidEnterBackground.</p> <p>in the appDelegate.h is this:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; #import "MapKit/Mapkit.h" @class MainViewController; @interface AppDelegate : UIResponder &lt;UIApplicationDelegate, MKMapViewDelegate, CLLocationManagerDelegate&gt; @property (strong, nonatomic) UIWindow *window; @property (strong, nonatomic) MainViewController *mainViewController; @property (strong, nonatomic) CLLocationManager *location; @property (weak, nonatomic) IBOutlet MKMapView *mapView; @property (nonatomic) BOOL disclaimerAccepted; @end </code></pre> <p>I want to achieve that locationservices is stopped (and the arrow disappear) when the user dismisses the app without having tapped the start button. How can this be done?</p> <p>BTW I can NSlog the flag in both methods when the NSLog statement is outside teh if statemen so the metods are "seen" just dif statement is not working (so it seems)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload