如何从子线程返回数据

时间:2016-10-14 03:08:10

标签: ios swift nsthread

  1. 正如标题中所述,如何从子线程返回数据
  2. 请帮我解决,非常感谢
  3.     func showMessage()->String
    {
        //sign up 
        user.signUpInBackgroundWithBlock { (successed, error) in
            if error == nil
            {
                    dispatch_async(dispatch_get_main_queue(), {
                    //load UI
                    self.message = ErrorTypeValue.showMessageWithError(error) as String
                  })
    
            }else
            {
                dispatch_async(dispatch_get_main_queue(), {
                    //load UI
                    self.showSuccess = true
    
                    self.message = self.showSuccessMessage()
    
                })
    
            }
        }
    
        return self.message!
    }
    

0 个答案:

没有答案