class WhateverViewController: UIViewController {
let locationManager = CLLocationManager() // here is the point of the @Zoli answer
// some code
override func viewDidLoad() {
super.viewDidLoad()
// some other code
locationManager.requestWhenInUseAuthorization()
// some other code
}
}
#import
@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;
}