使用 CLLocationManager 编写教程,我在 init 方法中设置委托:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
}
return self;
}
设置委托:
[locationManager setDelegate:self];
在另一个教程中,我在头文件中设置了委托:
@interface MyViewController : UIViewController <CLLocationManagerDelegate>
他们平等吗?有什么区别(如果有的话)?