Parse.com How to find out if an array contains an object

there is a method for pfquery

PFQuery *query = [PFQuery queryWithClassName:@"class"]; [query whereKey:(NSString *)key containsAllObjectsInArray:(NSArray *)array]; 

Is there a similar method for determining if the specified object is in the NO array? as

 [query whereKey:(NSString *)key doesNotContainAllObjectsInArray:(NSArray *)array]; 

If not, how do you code this method yourself?

+6
source share
3 answers

You can use the whereKey:notContainedIn: method for it. Please see the Parse documentation. Here is the sudo code from the link.

 // Finds scores from anyone who is neither Jonathan, Dario, nor Shawn NSArray *names = @[@"Jonathan Walsh", @"Dario Wunsch", @"Shawn Simon"]; [query whereKey:@"playerName" notContainedIn:names]; 
+3
source
 NSMutableArray *wantedObjects = [[NSMutableArray alloc] init]; [array enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { if (/*do logic to match key or obj*/) [wantedObjects addObject:obj]; }]; 

Now you can turn the specified enumeration into a function. You can return [wantedObjects copy], which is an NSArray.

0
source

If you want to find objects in which the Array key does not contain another object, you can simply use notEqualTo: as confirmed by the Parse developer here:

https://www.parse.com/questions/pfquery-not-include-any-object-in-array

0
source

Source: https://habr.com/ru/post/958093/


All Articles