title: LocationManager crash when app wakes for update
body: <p>Although it works normal when app is active, it crashes when app is terminated and wakes for location update</p>
  
  <p>My code to handle app wakes up for location update on <code>didFinishLaunchingWithOptions</code></p>
  
  <pre><code>@UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate, CLLocationManagerDelegate {
  
      let locationManager = CLLocationManager()
      var glat : String = ""
      var glong : String = ""
  
      func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -&gt; Bool {
  
           if launchOptions?[UIApplicationLaunchOptionsLocationKey] != nil {
    let locationManager = CLLocationManager() //or without this line, both crashes
                      locationManager.delegate = self
                      locationManager.desiredAccuracy = kCLLocationAccuracyBest
                      let status = CLLocationManager.authorizationStatus()
                      if (status == CLAuthorizationStatus.AuthorizedAlways) {
                          locationManager.startMonitoringSignificantLocationChanges()
                      }
                  }
  return true
      }
  </code></pre>
  
  <p>Here is the locationmanager delegate on AppDelegate</p>
  
  <pre><code> func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
  
              if  let lat = manager.location?.coordinate.latitude,
                  let long = manager.location?.coordinate.longitude {
                  print(glat + " " + glong)
  
                  glat = String(lat)
                  glong = String(long)
  
                  //Line 339
                  updateloc(String(lat), long: String(long))
              }
      }
  </code></pre>
  
  <p>Function to send location info to server</p>
  
  <pre><code>func updateloc(lat : String, long : String) {
  
          let session = NSURLSession.sharedSession()
  
          //Line 354
          let request = NSMutableURLRequest(URL: NSURL(string: "URLTO/updateloc.php")!)
          request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
          request.HTTPMethod = "POST"
          let data = "lat=\(lat)&amp;long=\(long)"
          request.HTTPBody = data.dataUsingEncoding(NSASCIIStringEncoding)
  
          let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
              if let error = error {
                  print(error)
              }
              if let response = response {
  
                  let res = response as! NSHTTPURLResponse
                  dispatch_async(dispatch_get_main_queue(), {
                      if (res.statusCode &gt;= 200 &amp;&amp; res.statusCode &lt; 300)
                      {
                          do{
                              let resultJSON = try NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions())
  
                              var success = 0
  
  
                              if let dictJSON = resultJSON as? [String:AnyObject] {
                                  if let successInteger = dictJSON["success"] as? Int {
                                      success = successInteger
  
                                      if success == 1
                                      {
                                      print("ok")
                                      }
  
  
                                  } else {
                                      print("no 'success' key in the dictionary, or 'success' was not compatible with Int")
                                  }
                              } else {
                                  print("unknown JSON problem")
                              }
  
  
                          } catch _{
                              print("Received not-well-formatted JSON")
                          }
  
                      }
                  })
              }
          })
          task.resume()
  
  
      }
  </code></pre>
  
  <p>Here is the crash log</p>
  
  <pre><code>Crashed: com.apple.main-thread
  0                          0x10015d998 specialized AppDelegate.updateloc(String, long : String) -&gt; () (AppDelegate.swift:354)
  1                          0x10015ddf8 specialized AppDelegate.locationManager(CLLocationManager, didUpdateLocations : [CLLocation]) -&gt; () (AppDelegate.swift:339)
  2                          0x100159d0c @objc AppDelegate.locationManager(CLLocationManager, didUpdateLocations : [CLLocation]) -&gt; () (AppDelegate.swift)
  3  CoreLocation                   0x1893d08b8 (null) + 21836
  4  CoreLocation                   0x1893ccaac (null) + 5952
  5  CoreLocation                   0x1893c6e48 (null) + 880
  6  CoreFoundation                 0x18262cf84 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20
  7  CoreFoundation                 0x18262c8bc __CFRunLoopDoBlocks + 308
  8  CoreFoundation                 0x18262ad04 __CFRunLoopRun + 1960
  9  CoreFoundation                 0x182554c50 CFRunLoopRunSpecific + 384
  10 GraphicsServices               0x183e3c088 GSEventRunModal + 180
  11 UIKit                          0x18783e088 UIApplicationMain + 204
  12                         0x10015a324 main (AppDelegate.swift:20)
  </code></pre>
  
  <p>App crashes when app wakes for a location update in <code>startMonitoringSignificantLocationChanges</code> mode</p>
  
  <p>I really can't see any mistake here. Anyone can help me to fix it ?</p>