[self.tableView reloadData]; 

I call inside the completionHandler block that is in the loading screen.

 NSURLSessionDataTask *downloadTask = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {} 

When the download is complete, the data should be updated (the debugger goes to reloadData), but after reloadData nothing happens, in the methods

  -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{} -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(nonnull NSIndexPath *)indexPath{} 

do not fall again. Important point: self.tableView by default does not know such a property, so I declare its property (binding it to the TableView in Main.storyboard)

  @property (weak, nonatomic) IBOutlet UITableView *tableView; 

enter image description here

    1 answer 1

    And you specified delegate and dataSource for self.tableView? If not, then you should definitely specify: self.tableView.delegate = self; self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.dataSource = self;

    The second option, since you are doing reloadData inside the completionHandler , you must specify that the update be in the main thread.

     dispatch_sync(dispatch_get_main_queue(), ^{ [self.tableView reloadData]; }); 
    • Added a screenshot, indicated himself in the Main.storyboard - StriBog
    • one
      Made changes in response - Vitali Eller
    • one
      dispatch_sync (dispatch_get_main_queue () - fundamentally wrong