ios - Parse & Swift- Randomizing images -


first, simple, how change blank uiimage view image have stored in parse? code far

   var query = pfquery(classname:"content")     query.getobjectinbackgroundwithid("mlwvjlh7pa") {         (post: pfobject?, error: nserror?) -> void in         if error == nil && post != nil {              //content.image = uiimage          } else {             println(error)         }     } 

on top of replacing blank uiimageview, how may make image replaced random? assume can't use objectid anymore, because specific row represents.

i first retreive objectids parse getobjectsinbackgroundwithblock, , select random objectid array in variable called objectid. way save user querying every object parse , using lot of data doing it.

second

getobjectinbackgroundwithid(objectid)     if error == nil {         if let image: pffile = objectrow["image"] as? pffile{         image.getdatainbackgroundwithblock {         (imagedata: nsobject?, error: nserror?) void in ->            if let imagedata = imagedata {              let imageview = uiimageview(image: uiimage(data: imagedata))            }         }      } 

at least works me.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -