在 NSMutableArray Parse iOS 中删除 currentUser

Delete currentUser in NSMutableArray Parse iOS

我想用 Parse 加载好友,但是删除了 currentUser 对象,我该怎么做?我做错了什么?

我尝试使用此代码,但它不起作用:

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.currentUser = [PFUser currentUser];

    PFQuery *query = [PFUser query];
    [query orderByAscending:@"name"];
    [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
        if (error) {
            NSLog(@"Error: %@ %@", error, [error userInfo]);
        }
        else {
            self.allUsers = objects;
            self.mutableAllUsers = [[NSMutableArray alloc] initWithArray:self.allUsers];
            [self.mutableAllUsers removeObject:self.currentUser];
            [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];
            NSLog(@"%@", self.mutableAllUsers);
        }
    }];

找到它: 在查询中添加 [query whereKey:@"objectId" notEqualTo:self.currentUser.objectId];。 :)

试试这样的:

[query whereKey:@"username" notEqualTo:currentUser.username]

应该可以:)