func setPostcommentData(postmodel:model1,index: IndexPath) {
btnReply.tag = index.section
lblName.text = postmodel.getFullName()
btnReply.setTitle("Reply", for: UIControlState.normal)
btnCount.setTitle("0", for: UIControlState.normal)
TxtViewComment.text = postmodel.description
lblTime.text = ChatDates.commentTimeData(postmodel.createdDate).dateString
}
cellComment.setPostcommentData(postmodel: model1,index:indexPath)
cellComment.setPostcommentData(postmodel: model2,index:indexPath)
cellComment.setPostcommentData(postmodel: model3,index:indexPath)
如何写泛型函数,使其接受不同的模型和数据集?
请告诉你如何设置与其他模型数据。如果代码从模型到模型非常不同,我不建议将其用于通用。 – Sweeper
每个模型从Basemodel继承。所有模型都是基础模型的子类,每个模型都有2-3种不同的属性,也可以从基础模型中获得。 @Sweeper – Amey
如果函数接受'ParentModel',它也接受所有的'Childs' – JuicyFruit