我正在使用Swift iOS 应用程序,Parse并且PFUser发现自己处于PFUser.current()由于同步问题而不能完全按照我想要的方式执行的情况。
出于这个原因,我试图使用:PFUser.getCurrentUserInBackground()。
我从下面的代码开始,灵感来自这里可以找到的内容:https ://github.com/BoltsFramework/Bolts-ObjC 。
但是这个文件可能有点过时了,它不太管用。
let userCheckTask = PFUser.getCurrentUserInBackground()
userCheckTask.continueWith {
(task: BFTask!) -> BFTask<AnyObject> in
if task.isCancelled() { // Error-1.
// the save was cancelled.
} else if task.error != nil {
// the save failed.
} else {
// the object was saved successfully.
var object = task.result() as PFObject // Error-2.
}
}
编译器给了我两个错误,这个在标记为“Error-1”的行上
Cannot invoke 'isCancelled' with no arguments
而这一行上的另一个标记为“Error-2”
Expression type 'PFUser?' is ambiguous without more context
我不知道“isCancelled”期待什么样的论点。
有谁知道如何解决这些问题?