Hi I'm new with swift and parse.com, I'm trying do populate my array with already saved images in parse, try to use the dispatch_async but don't know how this works, heres the code:
//imageArray declaration in table:
var imageArray: Array<UIImage> = []
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! CustomCell
var query = PFQuery(className: "ParseClass")
query.findObjectsInBackgroundWithBlock { ( objects: [AnyObject]?, error: NSError?) -> Void in
if(error == nil) {
let imageObjects = objects as! [PFObject]
for object in objects! {
let thumbNail = object["columnInParse"] as! PFFile
thumbNail.getDataInBackgroundWithBlock ({ (imageData: NSData?, error: NSError?) -> Void in
if (error == nil) {
if let image = UIImage(data:imageData!) {
//here where the error appears: Cannot invoke 'dispatch_async' with an argument list of type '(dispatch_queue_t!, () -> _)'
dispatch_async(dispatch_get_main_queue()) {
cell.image.image = self.imageArray.append( image )
}
}
}
})
}
}
else{
println("Error in retrieving \(error)")
}
}
return cell
}
Hope you people understand that code.