0

I want to load friends with Parse, but remove currentUser Object, how can I make it ? What am I making wrong ?

I tried with this code, but it doesn't work :

- (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 Answers 2

1

Find it : add [query whereKey:@"objectId" notEqualTo:self.currentUser.objectId]; in query. :)

Sign up to request clarification or add additional context in comments.

Comments

1

Try something like:

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

That should work :)

2 Comments

thanks man, but my reply is fine :) e.g : [query whereKey:@"objectId" notEqualTo:self.currentUser.objectId];
You are right, i think objectId is better. but both should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.