我想知道如何将数据从ViewController传递给单元格?如何将数据从VC传递到单元?
我是初学者,所以我可以监督显而易见的:P
我有一个家VC,当你按下一个commentButton你能持有的帖子的帖子ID CommentVC。 正如我想能够喜欢评论(这是完美的作品),并注意到用户有关他的评论被喜欢(现在不工作),我需要有postId不仅在评论VC(它拥有正确的一个),但也在小区中。
这是我从HomeVc传递数据到CommentVC
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "CommentSegue" {
let commentVC = segue.destination as! CommentViewController
let commentCell = CommentTableViewCell()
let postId = sender as! String
commentCell.postId = postId
commentVC.postId = postId
}
}
当我打印出CommentVc和CommentCell两个变量的代码,只有CommentVc显示正确的一个,而所述细胞具有“无”作为打印出来的声明。
任何想法如何通过它?
感谢它现在正在工作:) –
@Zash__ np不要忘记标记为正确的答案。快乐编码:) –
我已经做到了:) –