如何将数组限制为显示5个项目,然后单击按钮再加载5个

时间:2019-05-10 11:02:09

标签: arrays swift uitableview nsarray

我有一组评论,但我只想显示5条评论。 点击加载时,我想显示更多5条评论+ 5条新评论。

从api获取评论

if  let arr : NSArray = responseData as? NSArray {

    self?.arrComments = NSMutableArray()

    if arr.count != 0{

        self?.arrComments = arr.mutableCopy() as? NSMutableArray ?? []

        self?.tblView.reloadData()
    }
}

出队tableView单元格

if arrComments.count != 0 {
    if let myDict: NSDictionary = arrComments.object(at: indexPath.row) as? NSDictionary {        
        cell.lblComment.text = string(myDict, "Comment")
        cell.lblTime.text =  string(myDict, "CommentDate")

0 个答案:

没有答案