xcode - How to convert PFObject array in image view? -
sorry guys want try again reword understandable.
imagefiles array of pfobjects, 10 images
let randomnumber = imagefiles[int(arc4random_uniform(uint32(imagefiles.count)))] println(randomnumber)
and println gives me random image file array.
how put image view? meaning want random element of array viewable in uiimage view.
let image = uiimage(data: randomnumber anyobject as! nsdata)
closest i've got... no syntax error runtime
could not cast value of type 'pfobject' (0x105639070) 'nsdata' (0x106c97a48).
an actual image stored in parse not of format pfobject
, of type pffile
. reference pffile
stored within pfobject
.
i can imagine code/pseudocode end looking following:
let myrandomimagemetadata = imagefiles[int(arc4random_uniform(uint32(imagefiles.count)))] let imagefilereference: pffile = myrandomimagemetadata["imglink"]
the actual code depend on database structure i've asked here, never provided.
now have file reference, have download image data itself. can so:
imagefilereference.getdatainbackgroundwithblock { (imagedata: nsdata?, error: nserror?) -> void in if error == nil { if let imagedata = imagedata { let image = uiimage(data:imagedata) } } }
you can read more storing , retrieving images stored pffile
in parse here:
https://parse.com/docs/ios/guide#files-images
now, next problem have not known of while uploading images in first place. there high risk you've uploaded images parse badly in first place , images doesn't exist there @ all.
Comments
Post a Comment