how can I refresh the content of UITableView every 5 minutes?
Put an NSTimer in and shoot it off every 300 seconds to refresh table view?
create an NSTimer that calls a method 'foo' every 5 mins (in seconds), then in 'foo' just write
[self.tableView reloadData];
Checkout NSTimer and UITableViews reloadData.
Assuming that the view of the current controller is a UITableView, and that you have declared a NSTimer called timer in your controller, the following code should do the trick:
- (void)viewDidLoad {
timer = [NSTimer scheduledTimerWithTimeInterval:300.0
target:[self view]
selector:@selector(reloadData)
userInfo:nil
repeats:YES];
[super viewDidLoad];
}
UPDATE:
Someone else has proposed the use timerWithTimeInterval:target:selector:userInfo:repeats: which is basically the same as the scheduledTimerWithTimeInterval that I have used in my example.
They differ, though, in that scheduledTimerWithTimeInterval adds the timer to the current run loop, whilst with the timerWithTimerInterval method, you will need to add the timer to a run loop your self.