objective c - iOS - customize class method in a singleton -
i customizing 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 able write 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
, stopupdatinglocation
instance methods , how use them, while [cllocationmanager locationservicesenabled]
class method. have no idea how use in singleton class.
i have tries using as
+(bool)locationservicesenabled { return [smylocationmanager.smanager locationservicesenabled]; }
but not working expected. kindly add ideas.
since wrapping cllocationmanager using class, class method follows same technique.
your class contain method like,
+ (bool)locationservicesenabled { return [cllocationmanager locationservicesenabled]; }
Comments
Post a Comment