【发布时间】:2015-11-28 06:16:32
【问题描述】:
下面的函数只返回 false,可能是因为 user.singUpInBackgroundWithBlock 正在后台发生。
无论如何我可以从函数中获得预期的返回值吗?
var returnFlag:Bool = false
func signUpAction(email:String, password:String) -> Bool
{
let user = PFUser()
user.username = email
user.password = password
user.signUpInBackgroundWithBlock {
(succeeded: Bool, error: NSError?) -> Void in
if let error = error {
let errorString = error.userInfo["error"] as? NSString
print(errorString!)
// INTENDED RETURN
self.returnFlag = false
} else {
// INTENDED RETURN
self.returnFlag = true
}
}
return self.returnFlag
}
【问题讨论】:
标签: xcode swift parse-platform