I'm trying to pass the result from the query into the variable array
var petitions = [PFObject] = []
Then return that result. How I can do that in Swift?
func getPetitions(employeeId: String, employeeBusiness: String) -> [PFObject] {
var petitions: [PFObject] = []
var query = PFQuery(className:"Petitions")
query.selectKeys(["petitionDate", "availableFrom", "availableTo"])
query.whereKey("employeeId", equalTo:employeeId)
query.whereKey("employeeBusiness", equalTo:employeeBusiness)
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
if let objects = objects as? [PFObject] {
NSLog("Successfully retrieved \(objects.count) petitions.")
for object in objects {
petitions.append(object)
}
}
}
}
return petitions
}
Aucun commentaire:
Enregistrer un commentaire