I can get images using the following code. But, this is loading all images first. How can I get only one random image? I tried many ways, but I couldn't. Please fix code and help me.
func loadData() {
let query: PFQuery = PFQuery(className: "Posts1")
query.findObjectsInBackgroundWithBlock { (objects, error) -> Void in
if (error == nil){
for object in objects! as [PFObject]{
let imagefile = object["imageFile"] as! PFFile?
imagefile?.getDataInBackgroundWithBlock({
(imageData, error) -> Void in
if (error == nil) {
self.cameraView.image = UIImage(data:imageData!)
}
})
}
}
else{
}
}
}