Спасибо, Мохабитар, что ответили на этот вопрос для меня!Для ясности я разместил свой код для других пользователей.
Примечание: только соответствующие части показаны ниже.
AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate, CLLocationManagerDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, strong) CLLocationManager *myLocationManager;
@property (nonatomic, strong) CLLocation *currentLocation;
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
if([CLLocationManager locationServicesEnabled])
{
currentLocation_ = [[CLLocation alloc] init];
myLocationManager_ = [[CLLocationManager alloc] init];
myLocationManager_.delegate = self;
[myLocationManager_ startUpdatingLocation];
}
}
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
currentLocation_ = newLocation;
}
Другие ViewControllers.h
@property (strong, nonatomic) CLLocation *currentLocation;
Другие ViewControllers.m
- (void)viewDidLoad
{
[super viewDidLoad];
if([CLLocationManager locationServicesEnabled])
{
AppDelegate *appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate];
currentLocation_ = [[CLLocation alloc] initWithLatitude:appDelegate.currentLocation.coordinate.latitude longitude:appDelegate.currentLocation.coordinate.longitude];
}
}
Еще раз спасибо!