Я хочу ограничить свой параметр didselectrowat
, чтобы при наличии переменной loggedInUser
...
if loggedInUser = "master"
разрешить функцию как есть ... if loggedInUser = "bobby"
разрешить только эта функция возникает, когда indexPath = "bobby"
Как я могу реализовать это, не копируя весь мой код.
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let user = Userlist[indexPath.row]
let alert = UIAlertController(title: "Master Function", message: "Edit \(user.Username!) like a Boss", preferredStyle: .alert)
let updateaction = UIAlertAction(title: "Update", style: .default){(_)in
blah blah blah
}
let deleteaction = UIAlertAction(title: "Delete", style: .default){(_)in
blah blah blah
}
alert.addAction(updateaction)
alert.addAction(deleteaction)
alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
present(alert, animated:true, completion: nil)
}