I have an UIImage array, images, which is declared as
var images = [UIImage]()
I currently have pictures stored in there, and when I output it using the println() function, I get
[<UIImage: 0x195dc810>, <UIImage: 0x195da3e0>, <UIImage: 0x1950ab50>]
I was wondering how I could upload these images to Parse as one row.
Here is my full code of what I have now(not working):
@IBAction func saveToParse(sender: AnyObject) {
for var i = 0; i < images.count; i++
{
var objectForSave:PFObject = PFObject(className: "NewLog")
//error on this line below: [(UIImage)] does not have a member variable named 'objectAtIndex'
let imageData:NSData = NSData(data: UIImagePNGRepresentation(images.objectAtIndex(i) as! UIImage))
var imageFile:PFFile = PFFile(data: imageData)
imageFile.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
if success{
objectForSave.setObject(imageFile, forKey: "Image")
objectForSave.saveInBackgroundWithBlock({ (success:Bool, error:NSError?) -> Void in
if success{
//do smth
}else{
println(error)
}
})
}else{
println(error)
}
}, progressBlock: { (progress:Int32) -> Void in
})
}
}
Thank you.
Aucun commentaire:
Enregistrer un commentaire