Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PFUser *currentUser = [PFUser currentUser];
- PFObject *friendRequest = [self.friendRequests objectAtIndex:indexPath.row];
- PFUser *fromUser = [friendRequest objectForKey:@"from"];
- [PFCloud callFunctionInBackground:@"addFriendToFriendsRelation" withParameters:@{@"friendRequest":friendRequest.objectId} block:^(id object, NSError *error) {
- if (!error) {
- //add the fromuser to the currentUsers friends
- PFRelation *friendsRelation = [currentUser relationForKey:@"friends"];
- [friendsRelation addObject:fromUser];
- //save the current user
- [currentUser saveInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
- if (succeeded) {
- [self.tableView reloadData];
- }
- else {
- NSLog(@"Error, didn't save");
- }
- }];
- }
- else {
- NSLog(@"Error, JavaScript problem.");
- }
- }];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement