0
私のTableViewでスワイプを編集オプションに追加しようとしています。ユーザーが編集を押すと、新しいビューが開きます。editActionsとperformSegueを使用してUITableView行を編集しますか?
しかし、私は常に「もしsegue.identifier == 『ItemDetailsVS {』 『』とライン上のFUNCでエラー「editActionsForRowAt」を取得:致命的なエラー:オプションの値をアンラップしながら、予想外にnilを
セグエは、ストーリーボードに正しい名前を持っている。任意のアイデア?
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ItemDetailsVC" {
if let destination = segue.destination as? ItemDetailsViewController {
if let item = sender as? Item2 {
destination.itemToEdit = item
}
}
}
}
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let edit = UITableViewRowAction(style: .normal, title: "Edit"){ (action, indexPath) in
var segue: UIStoryboardSegue!
if segue.identifier == "ItemDetailsVC" {
if let objects = self.controller.fetchedObjects , objects.count > 0 {
let item = objects[indexPath.row]
self.performSegue(withIdentifier: "ItemDetailsVC", sender: item)
}
}
}
return [edit]
}
空の変数を作成して使用していますが、もちろんあなたにエラーが表示されます。[this](http://stackoverflow.com/questions/26089152/sending-data-with-segue-セグエの使い方を学ぶ – Tj3n