I have an array of strings, call it plants = [Plant](), where each of the strings is a plant characteristic. I read in the plant characteristics from a spreadsheet, breaking each record into individual characteristics with tabs for each cell. One characteristic is an image name that I use for a closeup image. I would like to replace the image name with an array of image names that I pass to a UICollectionView in place of the UIImageView I show for the single image. So I would like to modify the spreadsheet to have a cell that could be either image1, as now, or image1, image2, image 3, ... and read the resulting array in for the collection, which could have one or more images. I have no problem with the collectionview from string literals, but reading in the multiple images would seem to involve mixing an array of strings into my string array, and I am not clear whether that is possible. Is there an obvious way to do this? Sorry for the novice question.
hi,
it's a little hard to see exactly where you're going, especially when you write
"I have an array of strings, call it plants = [Plant](), where each of the strings is a plant characteristic."
in syntax, does this mean that Plant is simply a string, or that Plant is a struct of several String characteristics, one of which is the image name.
assuming that it's the latter, one might guess you have something like
struct Plant {
let characteristic1: String
let characteristic2: String
......
let imageName: String
}in this is case, you'd simply be replacing the type of imageName to be [String], rather than String.
as for the unseen spreadsheet in your question, one guesses here that you have the various characteristics of plants as its columns, and individual plants as its rows. you probably also have some code that reads the spreadsheet into you program by parsing the tab-delimited rows, one-by-one, and creating Plant structs for each.
if that's the case, consider using the column for the image name (now to be image names) to be as many names as you wish, separated by commas (there are no commas in the names themselves, right?). then parse the field for image name(s) into an array of Strings by separating everything on the commas.
happy to see some code if you have some!
and hope that helps,
DMG