オブジェクトをテーブルビューから詳細ビューに渡そうとしています。私はrevealviewcontrollerフレームワークを使ってメニューをスライドさせています。したがって、私はtableviewからrevealviewcontrollerへのsegueを作成する必要があり、ここから別のものを最終的なdetailviewcontrollerに作成する必要があります。間にrevealviewcontrollerを持つテーブルビューからオブジェクトへのパス
私は詳細ビューでオブジェクトを設定できません - そのようにするにはどうすればよいですか?
これは使用されるコードです:
if segue.identifier == "communityDetailSegue" {
// Get the cell that generated this segue.
if let selectedCommunityCell = sender as ? UITableViewCell {
let destination = segue.destinationViewController as!CommunityViewController
if let communityIndex = self.tableView.indexPathForCell(selectedCommunityCell) {
destination.community = self.communitiesOfCurrentUser[communityIndex.row]
print(self.communitiesOfCurrentUser[communityIndex.row].name)
}
}
}
そして、これは例外です。
は、型の値をキャストすることができませんでした「SWRevealViewController」(0x10027b9f0)に「CommunityViewController」
ありがとうございました!私はあなたの助言に従った - 今私は "MyRevealViewController(0x11b8fc)にタイプ 'SWRevealViewController'(0x2235004)の値をキャストできませんでした。サブクラスを実装するときに必要なその他のことは? – Burkart
はい、SWRevealViewControllerの代わりにInterface BuilderのViewControllerのクラスとしてMyRevealViewControllerを設定する必要があります。 – Lasse
ビューのinitメソッドを追加する必要がありますが、今は動作します。これに助けてくれてありがとう! – Burkart