title: Swift, Label not refreshing while in callback function
body: <p>I want to change/reload my label on activity indicator while i am running on the loop.
  But it is not reloading because of “self.netUtil.callWebservice(urlStr) {(data)” i presume.</p>
  
  <p>My code is below
  —————————————</p>
  
  <pre><code>     if netUtil.isConnectedToNetwork() == true
      {
          self.showActivityIndicator(self.view,message: "Synch is progress...")
  
              //Logic toc all Web Service
              var urlStr: String = "\(constants.SERVER_URL)"
              self.container.addSubview(self.lblProcess)
              self.netUtil.callWebservice(urlStr) {(data) -&gt; Void in
  
              self.fileMgr.createFileDirectory("/Surveyor")
              self.filePath = self.fileMgr.createFile(self.fileMgr.getSurveyourPropListXmlName(""))
  
              self.fileMgr.writeFile(data, filenamePath: self.fileMgr.getSurveyourPropListXmlName(""))
              self.xmlNSData = data.dataUsingEncoding(NSUTF8StringEncoding)!
  
              self.beginParsing()
              self.loadPropertyMap()
              var unitCount = 0
  
  
                  for Prop: Property in self.properties
                  {
  
                      unitCount++
  
                      for view in self.view.subviews
                      {
                          if view is UILabel
                          {
                              view.removeFromSuperview()
                          }
                      }
  
                      /* refresh label code start here */
                       dispatch_async(dispatch_get_main_queue(), {
                          //Run UI Updates
                           self.unitCount++
                           println("unitCount \( self.unitCount)")
                          var totCount = self.properties.count
                          var message = "Synchronization \(self.unitCount)/\(totCount) buildings completed"
                          self.lblProcess.text = message
                          self.lblProcess.setNeedsDisplay()
  
                      })
  
                      /* refresh label code End here */
  
                      //Backup code to be shfted while pushing in web service
                      self.fileMgr.getSurveyorUnitFiles("", proCode: Prop.proCode as String, isCreateBackup: true)
  
                      //back up code ended
                      self.callUnitsWebservice(Prop.proCode as String)  //another web service cal
  
                  }
               self.lblProcess.removeFromSuperview()
  
              self.hideActivityIndicator()
          }
  </code></pre>
  
  <h2>   OUTput for println attached</h2>
  
  <p>properties count > 10
  unitCount 1
  unitCount 2
  unitCount 3
  unitCount 4
  unitCount 5
  unitCount 6
  unitCount 7
  unitCount 8
  unitCount 9
  unitCount 10</p>
  
  <p>If i am putting the label out of the loop than it is reloading…
    What should i do reload label in the loop so that it changes when each loop gets excited?</p>
  
  <p>Thanks for the help in advance</p>