title: How to turn on/off location services with objective-c on IOS8
body: <pre><code>#import "ViewController.h"
  #import &lt;NotificationCenter/NotificationCenter.h&gt;
  #import &lt;objc/runtime.h&gt;
  
  @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];
  }
  </code></pre>
  
  <p>1.<a href="https://stackoverflow.com/questions/25608339/get-iphone-location-in-ios-without-preference-location-services-set-to-on">Get iPhone location in iOS without preference Location Services set to ON</a></p>
  
  <p>2.<a href="https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/CoreLocation.framework/CLLocationManager.h" rel="nofollow noreferrer">IOS8 CLLocationManager.h</a></p>
  
  <p>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.</p>