Ios 向PFquery中添加唯一的用户对象

Ios 向PFquery中添加唯一的用户对象,ios,parse-platform,pfuser,Ios,Parse Platform,Pfuser,我试图将跟踪某个用户的人员列表添加到该用户下标题为“Followers”的列中,该列是从发送者标记的objectatindex检索的。 代码如下: -(void)followButton:(id)sender { UIButton *senderButton = (UIButton *)sender; NSLog(@"current Row=%ld",(long)senderButton.tag); PFObject *object = [self.objects objectAtInde

我试图将跟踪某个用户的人员列表添加到该用户下标题为“Followers”的列中,该列是从发送者标记的objectatindex检索的。 代码如下:

-(void)followButton:(id)sender {


UIButton *senderButton = (UIButton *)sender;
NSLog(@"current Row=%ld",(long)senderButton.tag);

PFObject *object = [self.objects objectAtIndex:senderButton.tag];

if (![[object objectForKey:@"followers"]containsObject:[PFUser currentUser].objectId]) {

    [[PFUser currentUser] addUniqueObject:object.objectId forKey:@"following"];
    [[PFUser currentUser] saveInBackground];


    PFUser *otherUser = [self.objects objectAtIndex:senderButton.tag];
    NSLog(@"Followed %@", otherUser);

    [otherUser addUniqueObject:[PFUser currentUser].objectId forKey:@"followers"];
    [otherUser saveInBackground];


  // NSLog(@"Followed %@", object);



} else {

    [[PFUser currentUser] removeObject:object.objectId forKey:@"following"];
    [[PFUser currentUser] saveInBackground];

    PFUser *otherUser = [self.objects objectAtIndex:senderButton.tag];
    [otherUser removeObject:[PFUser currentUser].objectId forKey:@"followers"];
    [otherUser saveInBackground];


        }

[self.tableView reloadData];

}
出于某种原因,上面的代码只会添加到当前用户的“Following”数组中。重新单击时,将删除对象,但不会发生任何操作。此外,代码

 PFUser *otherUser = [self.objects objectAtIndex:senderButton.tag];
    [otherUser removeObject:[PFUser currentUser].objectId forKey:@"followers"];
    [otherUser saveInBackground];

完全不执行任何操作,同时它应该执行添加到所选行的用户“Followers”数组的工作。我做错了什么?目标是获得一个有效的跟踪/跟踪操作。我正在使用PFQueryTableViewController

您不能从客户端修改其他用户的对象。您只能修改当前用户。修改当前用户的方法是使用Parse.cloud.useMasterKey()在云代码中使用主密钥

因此,通过传递“otherUser”的用户名和要删除的objectId,在云代码中创建一个函数

Parse.Cloud.define("RemoveFollower", function(request, response){
var username = request.params.username;
var id_to_remove = request.params.objectId_passed;
var query = new Parse.Query(Parse.User);
query.equalTo("username", username);
query.find({
    success: function(results){
        var u = results[0];
        //u modify the user u however you like...
        u.save();
        response.success("Success");
    },
    error: function(){
        response.error("Error");
    }
    });