在getCArrayList方法中调用函数reloaddata()时,表视图不会重新加载

时间:2018-02-16 10:27:24

标签: ios uitableview swift4 xcode9

func getCArrayList(id:String, array:[NSDictionary] ){

    videolist = NSMutableArray()
    videoId = NSMutableArray()
    image = NSMutableArray()

    for i in 0 ..< array.count
    {
        let adict:NSDictionary = array[i] as! NSDictionary

        let bdict:NSDictionary = adict.object(forKey: "snippet") as! NSDictionary
        let cdict:NSDictionary = bdict.object(forKey: "resourceId") as! NSDictionary
        let ddict:NSDictionary = bdict.object(forKey: "thumbnails") as! NSDictionary
        let edict:NSDictionary = ddict.object(forKey: "medium") as! NSDictionary

        self.videolist.add(bdict.object(forKey: "title") as! String)
        self.videoId.add(cdict.object(forKey: "videoId") as! String)
        self.image.add(edict.object(forKey: "url") as! String)

        if videoId[i] as! String == id {
            self.videolist.remove(i)
            self.videoId.remove(i)
            self.image.remove(i)
        }

    }

    self.videotable.reloadData()

}

//calling the fuction:
 getCArrayList(id: videoid, array: didselectarray)

当调用此函数getCArrayList时,tableview不会重新加载 在tableview方法中调用函数didselectrowatindexpath() 我在哪里做错了?任何帮助表示赞赏....

1 个答案:

答案 0 :(得分:0)

请尝试以下方法:

DispatchQueue.main.async {
     self.videotable.reloadData()
}

希望它可能会有所帮助。