Have you tried using the Shared Instance? What you can do is try to manage your code with a single dispatcher instance. Thus, any change in the delegate can reflect in one class, from there you can manage your code.
Example: - .h
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
@interface LocationManager : NSObject <CLLocationManagerDelegate>
@property (nonatomic,strong) CLLocationManager *objLocationManager;
@property (nonatomic,assign) CLLocationCoordinate2D currentcoordinate;
+ (LocationManager *) SharedInstance;
+ (CLLocation *) currentLocation;
@end
.m
#define currentCordinates [LocationManager SharedInstance].currentcoordinate
#define currentLocationmanger [LocationManager SharedInstance].objLocationManager
static LocationManager *SharedInstance = nil;
+ (LocationManager *) SharedInstance
{
@synchronized(self)
{
if (SharedInstance == nil)
{
SharedInstance = [[super allocWithZone:NULL] init];
currentLocationmanger = [[CLLocationManager alloc]init];
currentLocationmanger.delegate = [LocationManager SharedInstance];
currentLocationmanger.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
currentLocationmanger.distanceFilter = 2.0f;
currentLocationmanger.headingFilter = 5;
[LocationManager SharedInstance].geocoder = [[CLGeocoder alloc] init];
[[LocationManager SharedInstance].objLocationManager startUpdatingLocation];
if ([CLLocationManager locationServicesEnabled]){
[currentLocationmanger startMonitoringSignificantLocationChanges];
}
}
}
return SharedInstance;
}
// other delegates and stuff to control in .m
In some cases, when you use, use the intace shared interface
region.center = [LocationManager SharedInstance].currentcoordinate;
source
share