I wanted to use drop down in my ios app using swift. so far I have achieved everything by watching this video of drop down I have created drop down using this link
but when i print button title
func tableView(_ tableView: UITableView, didSelectRowAt indexPath:IndexPath{ let buttonTitle = btntitle.setTitle("\(fruits[indexpath.row])", for:.normal) print(buttonTitle)}
it is displaying --> () <-- in my output. But I want the selected item name from the code.
Can anyone help me with this, please?
You are assigning the function setTitle (which returns void), to your buttonTitle variable. When you print that variable you're seeing () <- cause it's the empty return.
You probably are seeing a warning on that line.
Modify it like this:
let buttonTitle = fruits[indexpath.row]
btntitle.setTitle(buttonTitle, for: .normal)