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