Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. // Create local storage
  2. PFObject *localPhotos = [PFObject objectWithoutDataWithClassName:@"Photo" objectId:objectId];
  3. [localPhotos setObject:zero forKey:@"count"];
  4. [localPhotos pinInBackground];
  5.  
  6. PFQuery *query = [PFQuery queryWithClassName:@"Photo"];
  7. [query fromLocalDatastore];
  8. [[query getObjectInBackgroundWithId:objectId] continueWithBlock:^id(BFTask *task)
  9. {
  10. if (task.error)
  11. {
  12. // something went wrong
  13. return task;
  14. }
  15.  
  16. // task.result will be your object
  17. PFObject *object = task.result;
  18.  
  19. NSNumber *counts = object[@"count"];
  20.  
  21. // Update counts
  22. int count = [counts intValue];
  23.  
  24. count = count + 1;
  25.  
  26. counts = [NSNumber numberWithInt:count];
  27.  
  28. // Update UILabel
  29. _bestsCount.text = [NSString stringWithFormat:@"%@", bestCount];
  30.  
  31. [self alignImageView:_bestsLogoWrapper andLabel:_bestsCount inSuperView:_bests];
  32.  
  33. // NSLog(@"reachable: %d", isReachable);
  34.  
  35. // Update the local datastore
  36. PFObject *localPhotos = [PFObject objectWithoutDataWithClassName:@"Photos" objectId:photoObjectId];
  37. [localPhotos setObject:bestCount forKey:@"bestCount"];
  38. [localPhotos pinInBackground];
  39.  
  40.  
  41. return task;
  42. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement