Swift alternative to performSelectorOnMainThread

前端 未结 6 1284
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 14:20

I want to reload my table data inside a block in this method:

import UIKit
import AssetsLibrary

class AlbumsTableViewController: UITableViewController {

           


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 14:34

    You are calling performSelectorOnMainThread on UIViewController instead of UITableView's object

    May be your code:

    self.performSelectorOnMainThread(Selector(reloadData), withObject: self.tblMainTable, waitUntilDone: true)
    

    Instead of:

    self.tblMainTable.performSelectorOnMainThread(Selector("reloadData"), withObject: nil, waitUntilDone: true)
    

    you are getting that message because UIViewController does't have any method named "performSelectorOnMainThread"

提交回复
热议问题