我在viewDidLoad中有方法,看起来调用方法的顺序很奇怪。
- (void)viewDidLoad
{
[super viewDidLoad];
// Get Location
self.locationManager = [[CLLocationManager alloc] init];
self.geocoder = [[CLGeocoder alloc] init];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
if([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)])
{
[self.locationManager requestWhenInUseAuthorization];
}
[self.locationManager startUpdatingLocation];
// Retrieve Data
[self retrieveData];
}
在调用viewDidLoad之后,它会在locationManager之前调用retrieveData方法。
由于订单的原因,不应该在retrieveData之前调用locationManager吗?
我是Objective C的新手,感谢您的帮助。
答案 0 :(得分:1)
根据您的需要在委托方法中调用您的方法,因此从PartNumber.equals(Object)
移除[self retrieveData];
并添加到ViewDidLoad
或didFailWithError
方法内。
didUpdateLocations
注意
目标-C是解释器,它逐步执行每一个,所以或者可能是你的[self retrieveData];在主线程中调用,这就是它在先前执行的原因。