Reputation: 721
whats the best way to refresh data in a UITableView, lets say data is populated at start-up then this data changes, how could i refresh the data, every 30 seconds or give the option of the user to refresh the data.
i can populate data but unsure on how to update the data when it has been put in the UITableView.
Upvotes: 0
Views: 3156
Reputation: 31730
Use timer NSTimer
to update you UITabelView
after each 30 second.
Use NSTimer
NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 30.0 target: self
selector: @selector(callAfterThirtySecond:) userInfo: nil repeats: YES];
After each 30.0 second , iOS will call the below function
Make isStopUdating
as class member just like UITabelView
instance : if you want to discontinue of updating table then set isStopUdating
with YES,
-(void) callAfterThirtySecond:(NSTimer*) timer
{
if(isStopUdating)
{
[timer invalidate];
}
[myTableView reloadData];
}
Upvotes: 0
Reputation: 1751
If You Update regularly means
Use This
NSTimer * timerFade = [NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(get) userInfo:nil repeats:YES];
and
`-(void) get
{
your url process
[self.tableview reload data];
}
if you give the option for user You may directly call
[self get];
Upvotes: 0