无法检索用户个人资料图片Parse iOS swift

时间:2015-08-14 14:32:35

标签: ios swift parse-platform

我遇到这条线的问题

let userImageFile:PFFile = user["photo"] as PFFile

代码不会超出这一行。我试着在互联网上到处搜索。但无法理解错误。在我的下面的代码我总是得到“Something error”。但我的用户名检索工作正常。

    var user = spread.objectForKey("spreader") as! PFUser

    user.fetchIfNeededInBackgroundWithBlock { (obj: PFObject?, error: NSError?) -> Void in
        if obj != nil {
            var fetchedUser = obj as! PFUser
            var username = fetchedUser["username"] as! String
            cell.username.text = user.username

            //Profile Picture Retrieve

    if let userImageFile:PFFile = user["photo"] as? PFFile{ 
       println("working")
        userImageFile.getDataInBackgroundWithBlock {
            (imageData: NSData?, error: NSError?) -> Void in
            if (error == nil) {
                if imageData != nil{
                    cell.profileImage.image = UIImage(data:imageData!)
                }else{
                    println("No Data")
                }

            }else{
                println(error)
            }
        }

    }else{

        println("Something Error") // Always getting this

    }



        }
    }




    return cell
}

enter image description here

0 个答案:

没有答案