Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force Reload Table View

All,

How would I force reload a table view (within a view controller) every five seconds for fifteen seconds when a button is pressed?

Thanks, James

like image 563
Baub Avatar asked Mar 13 '26 16:03

Baub


2 Answers

First you create a timer when you press your button,

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(updateMethod) userInfo:nil repeats:YES];

Then in your method that fires every 5 seconds

- (void) updateMethod
{
   [self.tableView reloadData];
}
like image 196
Man of One Way Avatar answered Mar 15 '26 06:03

Man of One Way


Check out NSTimers & Apple Documentation. This will give you a concept about intervals and help you with the delay you are looking for.

And for reloading tableview, [self.tableView reloadData]; should to the trick.

like image 21
Legolas Avatar answered Mar 15 '26 07:03

Legolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!