Skip to content

Instantly share code, notes, and snippets.

@koromiko
Created October 5, 2017 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koromiko/7cd42d963f3d02bf88faac630a67705b to your computer and use it in GitHub Desktop.
Save koromiko/7cd42d963f3d02bf88faac630a67705b to your computer and use it in GitHub Desktop.
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
let photo = self.photos[indexPath.row]
if photo.for_sale { // If item is for sale
self.selectedIndexPath = indexPath
return indexPath
}else { // If item is not for sale
let alert = UIAlertController(title: "Not for sale", message: "This item is not for sale", preferredStyle: .alert)
alert.addAction( UIAlertAction(title: "Ok", style: .cancel, handler: nil))
self.present(alert, animated: true, completion: nil)
return nil
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment