Reputation: 149
Is it possible to save an array of images under one field-name in mlab.com/heroku running Parse Server. I'm trying to save 150 images in one field-name. I know how to save one image. But is it possible to save 150+ in one field-name.
Upvotes: 1
Views: 129
Reputation: 11928
You can't save an array of 'images', as in PFFiles
, but you can save an array of PFObjects
. So create an array of PFObjects
, each with the same class name, each with a PFFile
assigned to the same field name in that PFObject
, then save like so:
PFObject.saveAll(inBackground: myObjects, block: { result, error in
})
Then you'll also be able to retrieve all those files as well via retrieving the PFObjects
EDIT
Here is a quick sloppy example of how you might get started:
let objectA = PFObject(className: "Some")
objectsA["thumbnail"] = myPFFile1
let objectB = PFObject(className: "Some")
objectsB["thumbnail"] = myPFFile2
PFObject.saveAll(inBackground: [myPFFile1, myPFFile2], block: { result, error in
})
PFQuery.findObjectsInBackground({ result, error in
if let objects = result as? [PFObject], let first = objects.first, let thumbnail = first["thumbnail"] as? PFFile {
//can do something with thumbnail
}
})
Upvotes: 1