PFQueryTableView Auto Refresh When New Data Updated or Refresh Every Minute Using Parse

北城以北 提交于 2019-12-04 17:51:27

In .h file

@property (nonatomic, strong) NSTimer *fetchTimer;
@property (nonatomic, strong) NSArray *items;

In .m file

- (void)viewDidLoad
{
    NSTimer *timer = [NSTimer timerWithTimeInterval:3600
                                             target:(id)self
                                           selector:@selector(fetch)
                                           userInfo:nil
                                            repeats:YES];
    self.fetchTimer = timer;
}

- (void)fetch
{
    PFQuery *query = [PFObject query];
    [query whereKey:@"" equalTo:@""];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

        self.items = [NSArray arrayWithArray:objects];
        [self.tableView reloadData];
    }];
}

1) Set a NSTimer with 3600 intervalTime and trigger the fetch data function. 2) Just call [self.tableView reloadData] when the data has been fetch. It is all depends on how you design your coding structure.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!