I am customizing my singleton class of CLLocationManager
.
I have
@property (nonatomic, strong) CLLocationManager *sManager;
and
static MyLocationManager* sMyLocationManager=nil;
+(instancetype)sharedLocationManager{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sMyLocationManager = [[self alloc] init];
});
return sMyLocationManager;
}
I could able to write my own methods as
-(void)settingUserLocationManager{
if(nil== sMyLocationManager.sManager){
sMyLocationManager.sManager = [[CLLocationManager alloc] init];
}
-(void)onStartUpdatingUserLocation{
[sMyLocationManager.sManager startUpdatingLocation];
return;
}
-(void)onStopUpdatingUserLocation{
[sMyLocationManager.sManager stopUpdatingLocation];
}
startUpdatingLocation
and stopUpdatingLocation
are instance methods and this how I use them, while [CLLocationManager locationServicesEnabled]
is a class method. I have no idea how to use that in my singleton class.
I have tries using it as
+(BOOL)locationServicesEnabled {
return [sMyLocationManager.sManager locationServicesEnabled];
}
but not working as expected. Kindly add some ideas.
Since you are wrapping the CLLocationManager using your class, the class method follows the same technique.
Your class will contain a method like,
+ (BOOL)locationServicesEnabled
{
return [CLLocationManager locationServicesEnabled];
}