0
我可以使用下面的代码获取图像。但是,这是首先加载所有图像。我怎样才能得到一个随机图像?我尝试了很多方法,但是我做不到。请修复代码并帮助我。如何从Parse for iOS获取一张随机图像?
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{
}
}
}