Charlie Fish
Charlie Fish

Reputation: 20526

Swift UITableView On Reload Data

I have some code I want to run on the function onReload of my UITableView. Basically for now I just want to print how many items there are in an array. Later on I will want to display or not display a view depending on how many items there is.

So I want this code to run whenever the UITableView refreshes or reloads or anything like that.

How can I achieve that?

Upvotes: 1

Views: 98

Answers (1)

OmniBug
OmniBug

Reputation: 892

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    //dataArray is your data array
    // > 10 is your condition
    if dataArray.count >10{
        return 0
    }else{
        return dataArray.count
    }

}

Upvotes: 2

Related Questions