I want to save value in array and check if value in array exist.
I use this code:
to save value
var index = 0
var array = [Int]()
self.array.append(self.index)
But how I can check if value in array exist and show numbers values in array in console?
example:
check value
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
if "values for array exist" {
//show text for all row numbers in the array
}
}
save value in array
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
index = indexPath.row
self.array.append(self.index.row) //save row number
}