jeudi 5 juillet 2018

How can I make an if statement to determine what array to use in a tableView?

Using xcode 9.4, Swift 4 and ios 11, I want to select an item from a collection view screen that goes to a table view screen. On the table view screen I have a series of arrays and, depending on what I've chosen on the collection view screen, I want to display a specific array on the table view screen.

I've already set up the prepareForSegue function on the collection view screen that references a var on the table view, but I'm a bit stuck on the "select an array" bit. I'm pretty sure it involves an if statement, but I'm not sure how or where to put this if statement.

Any help would be greatly appreciated.

Here's the if statement that I made (I don't know if its correct):

    if cellItem == "jeans" {
        tableArray.append(jeanArray[])
    } else if cellItem == "skirts" {
        tableArray.append(skirtArray[])
    }

Then in the functions for the table set up, I've referenced tableArray.

Aucun commentaire:

Enregistrer un commentaire