I have been trying to create a "saved features" tab for my app. I embedded a button into my table view cell (which had a star icon - FavouriteStatusButton). When selected it would append the feature title (the name of the cell) to FavouriteFeatureDataBase.
@IBOutlet weak var FeatureTitle: UILabel!
var array1: [String] = []
var FavouriteFeatureDataBase = UserDefaults.standard
@IBAction func FavouriteStatusButton(_ sender: UIButton) {
array1.append(FeatureTitle.text!)
FavouriteFeatureDataBase.set(array1, forKey: "ArrayOfFilteredFeatures")
...
It only seems to do this one cell at a time - For example I select 4 cells,
1: Name1, 2: Name2, 3: Name3 and 4: Name4
Instead of getting ["Name1", "Name2", "Name3", "Name4"], I'll only get ["Name4"].
I suspect this is because it is in the UITableViewCell but I'm not sure.