Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSDictionary *someDict = [NSDictionary dictionaryWithObjectsAndKeys: @"Foo", @"Bar", @"Fizz", @"buzz", nil];
- SomeObj *anObject = [[SomeObj alloc] init];
- [anObject setDictionaryRepresentation:someDict];
- NSDictionary *someOtherDict = [NSDictionary dictionaryWithObjectsAndKeys: @"Food", @"Biz", @"Bazzz", @"Fizzle", nil];
- SomeObj *anotherObject = [[SomeObj alloc] init];
- [anotherObject setDictionaryRepresentation:someOtherDict];
- NSDictionary *someDictionarySameAsSomeDict = [NSDictionary dictionaryWithObjectsAndKeys: @"Fizz", @"buzz", @"Foo", @"Bar", nil];
- SomeObj *someThirdObject = [[SomeObj alloc] init];
- [someThirdObject setDictionaryRepresentation:someDictionarySameAsSomeDict];
- NSPredicate *isEqualTemplate = [NSPredicate predicateWithFormat:@"dictionaryRepresentation = $SOME_DICTIONARY"];
- NSPredicate *filter = [isEqualTemplate predicateWithSubstitutionVariables:[NSDictionary dictionaryWithObject:someDict forKey:@"SOME_DICTIONARY"]];
- NSArray *easyOne = [NSArray arrayWithObjects: anObject, anotherObject, nil];
- NSArray *someFilteredObjects = [easyOne filteredArrayUsingPredicate:filter];
- NSLog(@"%@ ", someFilteredObjects);
- assert([someFilteredObjects objectAtIndex:0] == anObject);
- NSArray *harderOne = [NSArray arrayWithObjects: someThirdObject, anotherObject, nil];
- someFilteredObjects = [harderOne filteredArrayUsingPredicate:filter];
- NSLog(@"%@ ", someFilteredObjects);
- assert([someFilteredObjects objectAtIndex:0] == someThirdObject);
- NSArray *hardestOne = [NSArray arrayWithObjects: anObject, someThirdObject, anotherObject, nil];
- someFilteredObjects = [hardestOne filteredArrayUsingPredicate:filter];
- NSLog(@"%@ ", someFilteredObjects);
- assert([someFilteredObjects containsObject:someThirdObject]);
- assert([someFilteredObjects containsObject:anObject]);
Add Comment
Please, Sign In to add comment