simlimsd3
simlimsd3

Reputation: 619

Retrieve Data in Parse

I have searched through a number of similar topics but have not found a solution as of yet. I am using Parse social and using the login files.

I get the following error:

"AnyObject?" is not convertible to 'String'

I am very new to Swift & Parse - I believe this is the correct method of retrieving data, so please correct me if I am wrong.

    var userObjectID = PFUser.currentUser()!.objectId!


    var query = PFQuery(className:"User")
    query.getObjectInBackgroundWithId("\(userObjectID)") {
        (userInfo: PFObject?, error: NSError?) -> Void in
        if error == nil && userInfo != nil {
            println(userInfo)
            let userScore = userInfo["level"] as! String
        } else {
            println(error)
        }
    }

Below is the database on Parse

Upvotes: 0

Views: 94

Answers (1)

Charlie Hall
Charlie Hall

Reputation: 577

I think you need to unwrap the PFObject you receive:

let userScore = userInfo!["level"] as! String

Upvotes: 1

Related Questions