0

I have strings that are set up in my class on parse, how do I pull those down in to an array.

I don't have any of my own code at the moment. I have found stuff that is in php or php but I cannot find anything in swift.

var query = PFQuery(className:"GameScore")
query.getObjectInBackgroundWithId("xWMyZEGZ") {
  (gameScore: PFObject!, error: NSError!) -> Void in
if error == nil && gameScore != nil {
  println(gameScore)
} else {
println(error)
  }
 }

I don't think its that because that is just retrieving an object.

In short is there a way to take Class > String and get all of the data in the column put into an array in my .swift?

1 Answer 1

1

What are you going to do with the array? As you will have all found data in the gameScore Object available you can do from there whatever you want to do.

var query = PFQuery(className:"GameScore")
query.getObjectInBackgroundWithId("xWMyZEGZ") {
   (gameScore: PFObject!, error: NSError!) -> Void in
if error == nil && gameScore != nil {
  println(gameScore)

  for singleScore in gameScore{
       println(singleScore) // this is the single result
       println(singleScore.objectId)
       println(singleScore["anyColName"])
  }

} else {
println(error.userInfo) // returns more details
  }
 }

Regarding your question:

var myArray: NSMutableArray! = NSMutableArray()

var query = PFQuery(className:"GameScore")
query.getObjectInBackgroundWithId("xWMyZEGZ") {
  (gameScore: PFObject!, error: NSError!) -> Void in
if error == nil && gameScore != nil {

     println(gameScore)
     var temp: NSArray = gameScore as NSArray
     self.myArray = temp.mutableCopy() as NSMutableArray // now you have all results in an array

} else {
println(error.userInfo)
  }
 }
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.