0

I'm trying to search for data that contains a certain string then download an array from that row. I know how to do this in objective-c but not in swift. Here's the code I have to search for it:

let query = PFQuery(className:"Wait")
        query.whereKey("latitude", equalTo:self.latitude)
        query.findObjectsInBackgroundWithBlock {
            (objects, error: NSError?) -> Void in

            if error == nil {

            }
        }

I'm not sure how to use "objects" to download the array from that row.

1 Answer 1

1

To make things more clear, this should be the closure signature:

query.findObjectsInBackgroundWithBlock {
     (objects : [PFObject]?, error: NSError?) -> Void in
            if error == nil {

            }
     }

Then you can iterate through objects like:

for object in objects {
   print(object)
}
Sign up to request clarification or add additional context in comments.

4 Comments

In the second part of the code, I can't find an object by object.[columnname]
Try using object.objectForKey(columnname) as someType
What do you mean by someType?
Well it could be any type, for example Int or String, depending on what type of data is in that column.

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.