Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. PFUser *currentUser = [PFUser currentUser];
  2. PFObject *friendRequest = [self.friendRequests objectAtIndex:indexPath.row];
  3. PFUser *fromUser = [friendRequest objectForKey:@"from"];
  4.  
  5. [PFCloud callFunctionInBackground:@"addFriendToFriendsRelation" withParameters:@{@"friendRequest":friendRequest.objectId} block:^(id object, NSError *error) {
  6.  
  7. if (!error) {
  8. //add the fromuser to the currentUsers friends
  9. PFRelation *friendsRelation = [currentUser relationForKey:@"friends"];
  10. [friendsRelation addObject:fromUser];
  11.  
  12. //save the current user
  13. [currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
  14. if (succeeded) {
  15. [self.tableView reloadData];
  16. }
  17. else {
  18. NSLog(@"Error, didn't save");
  19. }
  20. }];
  21. }
  22. else {
  23. NSLog(@"Error, JavaScript problem.");
  24. }
  25. }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement