-1

I have an array with ObjectIds:

var subjId:PFObject = [<Subjects: 0x16dy39c0, objectId: kmlgYQr4Qe, localId: (null)> {
}, <Subjects: 0x16de3df0, objectId: eYnor2QjLt, localId: (null)> {
}]

And I want to retrieve those objects, I've been looking around and I found that its done by FetchAllInBackground. My question is: How do you use FetchAllInBackground in Swift? I've looked around and I haven't found any documentation.

Omar Dlhz
  • 158
  • 12

1 Answers1

0

If you want to retrieve the objects of an Array of ObjectId's you should do the following query:

var query = PFQuery(className:"GameScore")
query.whereKey("objectId", containedIn: array)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]!, error: NSError!) -> Void in
if error == nil {
// The find succeeded.
NSLog("Successfully retrieved \(objects.count) scores.")
// Do something with the found objects
for object in objects {
    NSLog("%@", object.objectId)
}
} else {
// Log details of the failure
NSLog("Error: %@ %@", error, error.userInfo!)
}
}

Hope it helps anybody that encounters the same problem!

(The objectIds in the array should be of type String)

Omar Dlhz
  • 158
  • 12