删除NSMutableArray Parse iOS中的currentUser

时间:2015-06-03 13:01:52

标签: ios objective-c parse-platform nsmutablearray

我想用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);
        }
    }];

2 个答案:

答案 0 :(得分:1)

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

答案 1 :(得分:1)

尝试类似:

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

这应该有效:)