#import "ViewController.h"
#import <NotificationCenter/NotificationCenter.h>
#import <objc/runtime.h>
@interface CLLocationManager
+ (id)sharedManager;
+ (BOOL)locationServicesEnabled;
+ (void)setLocationServicesEnabled:(BOOL)enabled;
+ (BOOL)locationServicesEnabled:(BOOL)arg1;
@end
- (void)viewDidLoad
{
[super viewDidLoad];
id CLLocationManager1 = objc_getClass("CLLocationManager");
self.mySwitch.on = [CLLocationManager1 locationServicesEnabled];//this works fine
}
- (IBAction)doSomeThing:(UISwitch *)sender
{
id CLLocationManager1 = objc_getClass("CLLocationManager");
[CLLocationManager1 setLocationServicesEnabled:sender.selected];//this does't work.
[CLLocationManager1 locationServicesEnabled:sender.selected];
}
1.Get iPhone location in iOS without preference Location Services set to ON
I want turn on(off) my iphone6 location services in my app.but this code does't work on IOS8. I don't know why.