Parse.com 防止无法对类型进行比较查询:(空)

Parse.com prevent Cannot do a comparison query for type: (null)

我想阻止消息“Cannot do a comparison query for type: (null)”我不想解决它,因为我知道出了什么问题,但我想例外。如果查询没有找到任何东西...... NSLog 的东西。 (而不是崩溃)

这是我的代码:

PFQuery *requestsToCurrentUser = [PFQuery queryWithClassName:@"FriendRequest"];
    [requestsToCurrentUser whereKey:@"to" equalTo:self.currentUser];
    [requestsToCurrentUser whereKey:@"status" equalTo:@"pending"];
    [requestsToCurrentUser findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

        if (!error) {
            //this property stores the data for the tableView
            self.friendRequests = objects;
            //reload the table
            [self.tableView reloadData];

        } else {

            //error occcurred

        }
    }];

试着把这个

if(!self.currentUser){
     // No value in self.currentUser
     return;
}
PFQuery *requestsToCurrentUser = [PFQuery queryWithClassName:@"FriendRequest"];
[requestsToCurrentUser whereKey:@"to" equalTo:self.currentUser];
[requestsToCurrentUser whereKey:@"status" equalTo:@"pending"];
[requestsToCurrentUser findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {

    if (!error) {
        //this property stores the data for the tableView
        self.friendRequests = objects;
        //reload the table
        [self.tableView reloadData];

    } else {

        //error occcurred

    }
}];