So, I am making an app that requires to select various things. You can select these by swiping to the right of the UITableView. I am using a UIContextualAction and I am using a switch statement to order out the functions and executable statements. Once the UITableView Cell is selected, it is to run off of one of my switch statements. This is from the indexPath.row chosen. Now once each object is selected, it will append the name into an array.
My problem: Once the object is appended, the array does not add on. For instance, I pick Snapchat. The array has "Snapchat" in it. If I were to also chose Instagram, the array should append "Instagram". It does, but it forgets about the "Snapchat" in it too, and when it prints, it only prints 1 selected object. (Which was the last one I picked)
How could I make an array where I can add more objects without it forgetting
I have looked at doing if statements on the tableview cell that was selected. Nothing works, and was wondering how I could fix this, or find a solution
var array = [String]()
var choice = indexPath.row
switch choice {
case 0:
array.append("Instagram")
print(array)
case 1:
array.append("Snapchat")
print(array)
case 2:
array.append("VSCO")
print(array)
default:
print("Error")
print(array)
This is what I get when I select multiple and try to append the array.
["Instagram"]
["Snapchat"]
["VSCO"]
Error
as you can see, they are not in the array form.