0

I have a scene with json gets a facebook likes. I need automatic update for that scene (the screen must reload). when new data (in this case - facebook likes counts has been changed). I tried all samples over the web, but couldn't implement that.

ViewController.m:

AFHTTPRequestOperationManager *FaceBookLikes = [AFHTTPRequestOperationManager manager];
NSString *FBlikes = [[NSUserDefaults standardUserDefaults] objectForKey:@"faceBookUrlField"];
NSString *FBLstr = [NSString stringWithFormat:@"http://graph.facebook.com/%@", FBlikes];
[FaceBookLikes GET:FBLstr parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

    self.posts = (NSDictionary *) responseObject;
    self.post = self.posts [@"likes"];
    NSLog(@"FB LIKES: %@", self.post);
    labelFacebookLikesCount.text = [NSString stringWithFormat:@"%@", self.post];

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"Error: %@", error);
}];

I will welcome any solving:

  1. update (refresh screen) when json counts has changed.
  2. update by time (for example) each 30 seconds.

1 Answers1

1

You need to invalidate whatever view you want to refresh.

So in your case,

[self.viewToRefresh setNeedsDisplay];

Call this after you have updated your values.

A O
  • 5,516
  • 3
  • 33
  • 68