I'm New to Coding and this is my first post on S/O I'm working on a little project Single View App with multiple pages.
I am trying to create a secondary array from an existing string array with references. I don't want to replicate all the data as the mainArray would handle any future changes.
I have over 50 other arrays to setup each with same and different Items all taken from the mainArray. The mainArray contains around 170 items in my code.
I have replicated the concept of what I need in this example, I cannot find the answer anywhere online, maybe I'm not searching using the correct terminology?
I want to set the coding to name a command within a func setSecondaryArray() 'nameArray' and this will determine which array the UICollectionView reads and displays in the page using a UIButton elsewhere in code. I can't get the basic secondaryArray to recognise the mainArray items. Any help would be appreciated.
Thank you.
let mainArray = ["Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8",
"Item 9" ]
let secondArray = [ mainArray[0], mainArray[4], mainArray[6] ]
let thirdArray = [ mainArray[1], mainArray[3], mainArray[7], mainArray[8] ]
func setSecondArray() {
nameArray = secondArray
}
//nameArray.count code going here to form a layout of the UIButtons