0

(I'm new to programming and totally new to Parse, so simplified explanations are certainly appreciated)

I imagine this is pretty straightforward; I'm just stuck. I have a PFObject saved in Parse.com that contains an array containing strings. I'm trying to set an array in my Swift app with the values in the Parse array.

var query = PFQuery(className:"ParseHat")
query.getObjectInBackgroundWithId("xxxxxxxxxx")
submittedNames = query["theHat"] as [String]
// submittedNames is declared elsewhere in the code. "theHat" is the key where 
the array is stored in the PFobject

I get the error 'PFQuery' does not have a member named 'subscript'. I've tried doing a few things I didn't fully understand to the code but have gotten other errors so I'm just posting this as it seems to most closely resemble the method for retrieving objects in the Parse docs.

1 Answer 1

0

Try this out...

var query = PFQuery(className: "ParseHat")

query.getObjectInBackgroundWithId("XXXXXXXXX") {
    (objects: PFObject?, error: NSError?) -> Void in

    if error == nil {

        //fetching users

        for object in objects{ //looping through returned data

            self.resultsArray.append(object.objectForKey("XXXXXXXX") as! String)

            //adding the string to var resultsArray = [String]()

        }

    } else {
        println("error :(")

    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.