0

I want the user to upload an image, and other users leave replies to that image, everything works fine so fat except i can't get save the replies inside the "replies" object/column in Parse into my local array in order to display them. it can't accept the : for in method.

override func viewDidLoad() {
    super.viewDidLoad()


        var query = PFQuery(className:"Posts")
        query.getObjectInBackgroundWithId(cellID) {
            (objects: PFObject!, error: NSError!) -> Void in
            if error == nil {

                println(objects["replies"])

                self.repliesArray.append(objects["replies"] as String) // <- problem Here

            } else {

                println("Error retreiving")
                self.displayError("Error", error: "Error retrieving")

            }

    }

}

1 Answer 1

1

If the replies column is a string, try this:

if error == nil {
    var array = objects.objectForKey("replies") as [String]
    for obj in array {
        self.repliesArray.append(obj as String)
    }
}
Sign up to request clarification or add additional context in comments.

8 Comments

error : 'PFObject' does not have a member called 'count'
What is the type of column "replies"?
Array, i can post to it perfectly.
An array of what? Strings? If so, try the new code.
gave me an error so i did this : " for object in array { self.repliesArray.append(object as String)}" But you sure helped me get there, so thank you.
|

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.