ios - Display random image with ImageView -
i able pull array of images parse.com after fiddling tutorials.
from array want throw on image view via next random image swipe gesture:
var query = pfquery(classname:"cats") query.findobjectsinbackgroundwithblock {(objects: [anyobject]?, error: nserror?) -> void in if error == nil { // find succeeded. object in objects! { // update - replaced as! self.imagefiles.append(object as! pfobject) println(self.imagefiles) self.view.addgesturerecognizer(rightswipe) } } else { // log details of failure println(error) } } }
the println(self.imagefiles)
shows array of files great, i'm having issues using random generator.
still new syntax, trying imageview.image = imagefiles[0]
or display 1 of images in array. not sure syntax though.
i'm guessing once imageview.image = imagefiles[randomnumber]
or equivalent.
for swipe part think got under control
edit
ok have:
let randomnumber = imagefiles[int(arc4random_uniform(uint32(imagefiles.count)))] println(randomnumber)
and println gives me random image file array.
how put image view?
edit tried:
for randomnumber in imagefiles { self.imageview.image = randomnumber }
and got:
cannot assign value type pfobject value type of uiimage
self.imageview.image = uiimage(data: randomnumber)
also gives me error can't have data: pfobject
Comments
Post a Comment