07-21-2023, 10:22 PM
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>
- 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>