0
我一直在查詢好友請求數據庫,但它返回整個表。約束是2個解析用戶和一個int。有沒有一個已知的錯誤,或者在我的代碼中有錯誤?我在android上做了同樣的查詢,它工作正常。複合查詢返回整個數據庫
PFUser * unwanted = [self.allFriends objectAtIndex:2];
self.currentUser = [PFUser currentUser];
NSLog(@"unwanted %@",unwanted);
PFQuery *query1 = [PFQuery queryWithClassName:@"friendrequest"];
[query1 whereKey:@"user1" equalTo:self.currentUser];
[query1 whereKey:@"user2" equalTo:unwanted];
[query1 whereKey:@"status" equalTo:@3];
PFQuery *query2 = [PFQuery queryWithClassName:@"friendrequest"];
[query1 whereKey:@"user1" equalTo:unwanted];
[query1 whereKey:@"user2" equalTo:self.currentUser];
[query1 whereKey:@"status" equalTo:@3];
PFQuery *query3 = [PFQuery queryWithClassName:@"friendrequest"];
[query1 whereKey:@"user1" equalTo:self.currentUser];
[query1 whereKey:@"user2" equalTo:unwanted];
[query1 whereKey:@"status" equalTo:@1];
PFQuery *query4 = [PFQuery queryWithClassName:@"friendrequest"];
[query1 whereKey:@"user1" equalTo:unwanted];
[query1 whereKey:@"user2" equalTo:self.currentUser];
[query1 whereKey:@"status" equalTo:@1];
PFQuery *finalQuery = [PFQuery orQueryWithSubqueries:@[query1,query2,query3,query4]];
[finalQuery findObjectsInBackgroundWithBlock:^(NSArray *objects,NSError *error){
if(!error){
NSLog(@"gotem %lu",(unsigned long)objects.count);
}
}];
哈哈哈感謝有時你只需要另一套眼睛,或者只是更好的編碼技能。 – waffles
儘快找到良好編程習慣的習慣,男人。我正在努力爲生產應用上的懶惰編程而努力...... –