title: Swift location manager
body: <p>I have problem with location in Swift.</p>
  
  <p>On simulator works fine but on device not working</p>
  
  <p>I use simulator iPhone 6 iOS 8.3 and device iPhone 6 iOS 8.3</p>
  
  <p>my code:</p>
  
  <pre><code>import UIKit
  import CoreLocation
  
  @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate,
  CLLocationManagerDelegate {
  
    var window: UIWindow?
    var locationManager: CLLocationManager! = nil
    var isExecutingInBackground = false
  
    func locationManager(manager: CLLocationManager!,
      didUpdateToLocation newLocation: CLLocation!,
      fromLocation oldLocation: CLLocation!){
        if isExecutingInBackground{
          println(newLocation);
          locationManager.stopUpdatingLocation()
        } else {
          /* We are in the foreground. Do any processing that you wish */
        }
    }
  
   func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool
   {
      locationManager = CLLocationManager()
      locationManager.desiredAccuracy = kCLLocationAccuracyBest
      locationManager.requestAlwaysAuthorization()
      locationManager.delegate = self
      locationManager.startUpdatingLocation()
      return true
    }
  
  
  
    func applicationDidEnterBackground(application: UIApplication) {
      isExecutingInBackground = true
      var timer = NSTimer.scheduledTimerWithTimeInterval(30, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
  
  
      /* Reduce the accuracy to ease the strain on
      iOS while we are in the background */
      locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters
    }
  
      func update() {
          println("test");
          locationManager.startUpdatingLocation()
      }
  
    func applicationWillEnterForeground(application: UIApplication) {
      isExecutingInBackground = false
  
      /* Now that our app is in the foreground again, let's increase the location
      detection accuracy */
      locationManager.desiredAccuracy = kCLLocationAccuracyBest
    }
  }
  </code></pre>
  
  <p>I want get location every 30 seconds</p>
  
  <p>so why not working on device?</p>