You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func findAsync(query:PFQuery<PFObject>) -> BFTask<[PFObject]> {
let task = BFTaskCompletionSource<[PFObject]>()
query.findObjectsInBackground { (results:[PFObject]?, error:Error?) in
if (error == nil) {
task.setResult(results!)
} else {
task.setError(error!)
}
}
return task.task
}
unfortunately, the above code throws the error
Type [PFObject] does not conform to protocol for 'AnyObject'
however, I need to type as [PFObject] to put the results of the query as the result to the task.
how do I accomplish this in Swift 3?
i was able to get past the error by using NSArray, however the result for the function never seems to get set, waituntilfinished just hangs.
func findAsync(query:PFQuery<PFObject>) -> BFTask<NSArray> {
let task = BFTaskCompletionSource<[NSArray]>()
query.findObjectsInBackground { (results:[PFObject]?, error:Error?) in
if (error == nil) {
task.setResult(NSArray.init(results!))
print(task.task.result!) // at this point i can verify that the result appears to be the desired
} else {
task.setError(error!)
}
}
return task.task
}
but calling the function with self.findAsync() with a query i know returns data, just simply returns nil or an uncompleted task
The text was updated successfully, but these errors were encountered:
unfortunately, the above code throws the error
however, I need to type as [PFObject] to put the results of the query as the result to the task.
how do I accomplish this in Swift 3?
i was able to get past the error by using NSArray, however the result for the function never seems to get set, waituntilfinished just hangs.
but calling the function with self.findAsync() with a query i know returns data, just simply returns nil or an uncompleted task
The text was updated successfully, but these errors were encountered: