在我的视图控制器中,我有一个标签,该标签具有由 PFQuery 从 Parse.com 调用的计数器数据的功能,这些数据可能随时更改。
我需要在数据浏览器中的数据更改时自动更新此标签,即使用户不在应用程序中航行。
假设我需要对 TableView 的标签进行某种自动重新加载。我该怎么办?有谁知道正确的方法?
这很简单,假设您的单元格中有一个pfLabel
。
使用以下委托方法实现查询:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
..................
// Do stuff here.
PFQuery *yourQuery = [PFQuery queryWithClassName:@"YOUR_PARSE_CLASS_NAME"];
// Implement your query constraint here, after that, get your desired data and show it using your desired label
[yourQuery findObjecsInBackgroundWithBlock:^(NSString* obj) {
pfLabel.text = obj;
}];
// Congrat, you just have your label asynchronously showed your parse data.
.....................
}