无法在 objective c 中调用用户定义的方法

couldn't call the user defined method in objective c

我正在使用核心定位框架。我正在用用户定义的方法检查授权状态 (kCLAuthorizationStatusDenied/kCLAuthorizationStatusRestricted)。
值得注意的一点是在正常执行流程(没有问题)的情况下调用此方法。

但在用户 quit/terminated 应用程序并再次重新启动它的情况下(通过点击应用程序图标)。在这种情况下,将调用 before 和 after 方法,只有 this(Authorization()) 方法不会调用。 为什么会发生这种突然的行为? 谁能告诉我 Objective C 中的执行流程?

在 .h 文件中 -

@property (strong, nonatomic) LocationTracker * locationTracker;

在 .m 文件中 -

    [self userTrialMethodBefore];
      [self.locationTracker startLocationTracking];
      [self userTrialMethodAfter];

- (void)userTrialMethodBefore
        { 
           NSLog(@"This method gets called before ");

         }


        - (void)startLocationTracking
        { 
            NSString *responeParam = @"";
            if ([CLLocationManager locationServicesEnabled] == NO)
            {
                responeParam = @"Disabled location";
            }
            else
            {

                CLAuthorizationStatus authorizationStatus= [CLLocationManager authorizationStatus];


                if(authorizationStatus == kCLAuthorizationStatusDenied || authorizationStatus == kCLAuthorizationStatusRestricted)
                {
                    responeParam = @"Unauthorize location";

                }
                else
                {
                    responeParam = @"Authorize location";


                    CLLocationManager *locationManager = [LocationTracker sharedLocationManager];
                    locationManager.delegate = self;
                    locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
                    locationManager.distanceFilter = kCLDistanceFilterNone;
                    if (SystemVersion > 9.2)
                    {

                        [locationManager setAllowsBackgroundLocationUpdates:YES];
                        locationManager.pausesLocationUpdatesAutomatically = false;
                    }

                    [locationManager startUpdatingLocation];
                }
            }
        }

- (void)userTrialMethodAfter
        { 
           NSLog(@"This method gets called after ");

         }

[注意:我使用的是Xcode9.2,iOS11.2.2设备,objective c语言]

分配 CLLocationManager 时,您还需要像这样调用 requestWhenInUseAuthorization

self.locationManager = [[CLLocationManager alloc] init];
[self.locationManager requestWhenInUseAuthorization];

以及为什么您不使用 self.locationTrackerstartUpdatingLocation 而是检索 sharedLocationManager?