Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 669 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Current location permission dialog disappears too quickly

#11
I met same situation of yours.

- My solution was changed from local variable to member instance.
- The cause was that the local?instance was invalid after the method was finished which includes the local the variable(of extend my locationManager)
- My Env.: Xcode9.3.1

<pre>

#import <MyLocationService.h>
@interface ViewController ()

@end

@implementation ViewController
@synthesize locManager; // after
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

//MyLocationService *locManager = [[BSNLocationService alloc]init:nil]; // before. the loc. delegate did not work because the instance became invalid after this method.
self->locManager= [[MyLocationService alloc]init:nil]; // after
locManager.startService;
}

</pre>
Reply

#12
I have faced the similar situation. After debugging I found

```
let locationManager = CLLocationManager()
```

is called in a method scope, but it should be called globally.

Why?

In a nutshell, locationManager has been released after the method had returned. But it shouldn't be released until user give or deny permission
Reply

#13
I had the `locationManager` as instance var but still that did not help in Swift 5, Xcode 11 (see below):


class MapViewController: UIViewController {

var locationManager: CLLocationManager {
let locationManager = CLLocationManager()
locationManager.desiredAccuracy = .greatestFiniteMagnitude
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
return locationManager
}

override func viewDidLoad() {
super.viewDidLoad()
locationManager.startUpdatingLocation()
}
}



However, making `locationManager` var lazy fixed the issue:

class MapViewController: UIViewController {

lazy var locationManager: CLLocationManager = {
let locationManager = CLLocationManager()
locationManager.desiredAccuracy = .greatestFiniteMagnitude
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
return locationManager
}()

override func viewDidLoad() {
super.viewDidLoad()
locationManager.startUpdatingLocation()
}
}

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through