Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用PFUser.getCurrentUserInBackground()时出错_Ios_Swift_Parse Platform_Pfuser_Parse Ios Sdk - Fatal编程技术网

Ios 使用PFUser.getCurrentUserInBackground()时出错

Ios 使用PFUser.getCurrentUserInBackground()时出错,ios,swift,parse-platform,pfuser,parse-ios-sdk,Ios,Swift,Parse Platform,Pfuser,Parse Ios Sdk,我在Swift iOS应用程序中使用了Parse和PFUser,发现自己遇到了这样的情况:由于同步问题,PFUser.current()不能完全满足我的要求 因此,我尝试使用:PFUser.getCurrentUserInBackground() 我是从下面的代码开始的,灵感来自这里: 但这份文件可能有点过时,它不太管用 let userCheckTask = PFUser.getCurrentUserInBackground() userCheckTask.continueWith {

我在Swift iOS应用程序中使用了
Parse
PFUser
,发现自己遇到了这样的情况:由于同步问题,PFUser.current()不能完全满足我的要求

因此,我尝试使用:PFUser.getCurrentUserInBackground()

我是从下面的代码开始的,灵感来自这里:

但这份文件可能有点过时,它不太管用

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.
    }
}
这一行上的另一个标记为“错误-2”

我不知道“isCancelled”所期待的是什么样的争论

有人知道如何解决这些问题吗?

让userCheckTask=PFUser.getCurrentUserInBackground()来解决
let userCheckTask = PFUser.getCurrentUserInBackground()
userCheckTask.continueWith {
    (task: BFTask) -> BFTask<AnyObject> in
    if let e = task.error {
        return BFTask(error: e)
    } else {
        return BFTask(result: task.result)
    } 
}
userCheckTask.continueWith{ (任务:BFTask)->中的BFTask 如果让e=task.error{ 返回任务(错误:e) }否则{ 返回任务(结果:task.result) } }
用PFUser替换任何对象。谢谢您的建议。我刚刚尝试用PFUser替换任何对象,但仍然得到完全相同的2个错误。我确实没有像您那样将“task.isCancelled()”替换为“task.isCancelled”,但我使用您的代码得到了另一个错误:“在预期返回“BFTask”的闭包中缺少返回”。是的,您必须返回PFUser对象。该操作的说明是什么?“还吗?”。换句话说,在这个上下文中,“PFUser对象”是什么意思?好的。谢谢,至少现在可以编译了。我需要试着仔细看看,看看这是否解决了我的问题。我已经尝试了代码,但它并没有做很多我能看到的好事。我还没来得及登录,它就已经通过了success分支。因为我一直指望它来获取凭证信息,所以这并不像我预期的那样有效。或者我做错了什么。
Expression type 'PFUser?' is ambiguous without more context
let userCheckTask = PFUser.getCurrentUserInBackground()
userCheckTask.continueWith {
    (task: BFTask) -> BFTask<AnyObject> in
    if let e = task.error {
        return BFTask(error: e)
    } else {
        return BFTask(result: task.result)
    } 
}