title: Grand Central Dispatch in Swift only works the first run
body: <p>I got a method which works like a refresher which uses the GCD pattern as shown below:</p>
  
  <pre><code>    func getStepsForTheWeek() {
      let concurrentQueue : dispatch_queue_t  = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
  
      dispatch_async(concurrentQueue, {
  
          // Create an array of Days.
          var days = [Day]()
  
          dispatch_sync(concurrentQueue, {
              print("first")
  
              for day in 0...7 {
  
                  let date = self.getDate(day)
  
                  // Get the date the day after that day.
                  let endDate = self.getDateDayAfter(date)
  
                  // Create a Day.
                  var day = Day(date: date)
  
                  self.pedometer.queryPedometerDataFromDate(date, toDate: endDate, withHandler: {numberOfSteps, error in
                      print("fetching")
  
                      if error != nil {
                          print("There was an error requesting data from the pedometer: \(error)")
                      } else {
                          day.steps = numberOfSteps!.numberOfSteps as Int
                          days.append(day)
                      }
                  })
              }
          })
  
          dispatch_sync(dispatch_get_main_queue(), {
              print("second")
  
              self.historyViewController.days = days
              self.historyViewController.reloadHistory()
          })
      })
  }
  </code></pre>
  
  <p>When the app starts the method works as it is intended to.
  But when the app is in the background and when I'm going back to the app I got this Observer which calls the method again to refresh its content.</p>
  
  <pre><code>        NSNotificationCenter.defaultCenter().addObserver(self, selector: "appBecomeActive", name: UIApplicationWillEnterForegroundNotification, object: nil )
  </code></pre>
  
  <p>But everytime I do this the second code-block is running before the first one.
  Any help?</p>