I wonder if its possible to store both Data and String in a array? I need a way to store images that user picks together with the image names inside a array so I later can append it to my API request when I upload it.
Now I am using a array tuple that I later append Data and String to
var imgArray = [(Data, String)]()
Then I add data to that array tuple like this:
if let firstImage = self.firstImage {
if let firstImageData = firstImage.compressImage() {
self.imgArray.append(firstImageData, self.randomImageName(length: 15))
}
I use the code above for everyimage the user uploads and it works, imgArray gets populated with both Data and String which I later send to my API.
But is there a way to use a array to store Data and String values to?
I am not sure if tuples is the best solution }
parameters["images"] = imgArray.map{$0.1}