在我的应用中,可以添加成员并向其显示tableView
中的成员。如果用户选择一个单元格,则他将转到transactionsVC
,其中显示用户的所有交易。用户可以将新交易添加到成员。我想添加一种可能性,即用户可以将事务添加到多个成员。
我希望在View
(用户可以添加新交易)中,有一种方法可以访问tableView
,其中显示俱乐部的所有成员。
我如何显示俱乐部的所有成员?
我现在有这个:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let destination = segue.destination as? MultipleMemberTransactionsViewController
else {
return
}
destination.club = club
}
我认为我必须在行中插入club
以外的内容:
destination.club = club
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "memberViewController") as! MemberViewController
destinationVC = vc
let selectedRow = self.tableViewClub.indexPathForSelectedRow?.row
vc.club = clubs[selectedRow!]
}
self.navigationController?.pushViewController(destinationVC, animated: true)
}
答案 0 :(得分:1)
您认为是正确的方法。您必须在目标视图控制器中为您的成员创建一个新属性,如下所示:
var members: (the type of your choice here certainly an array or dictionary) ?
然后在prepare(for:sender :)函数内部,将成员传递到目标视图控制器,如下所示:
destination.members = yourMembers
然后使用成员列表填充表视图。