You cannot check the row count in viewDidAppear
because an asynchronous NSURLConnection
is used to fetch the JSON data that populates the table view.
The correct way is to call reloadData
in connectionDidFinishLoading
, after you have updated your data source with the response from the URL request. At that point you know if the number of rows is zero or not, and there is no need to wait for the table view update to complete.
solved Display Alert if tableView has no Results