Question

in my view controller I have a label that has the function of counter data that are invoked by a PFQuery from Parse.com .. these data may change at any time.

I need this label is updated automatically when the data changes in databrowser even if the user is not sailing in the app.

Let's say that I would need some kind of automatic reload of the label as to the TableView. How can I do? Does anyone know the correct method?

Was it helpful?

Solution

It's quite simple, assume that you have a pfLabel in your cell.

Implement your query in the following delegate method:

- (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.
.....................
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top