I have entity in code data called "Location" and "Location" entity have around 50 attributes.
I used following predicate to check given value matches with any attribute from "Location" entity (i don't want to match it with any particular attribute but all attribute from entity)
NSString *enumKey=@"Pune";
NSArray *enumListForDeleteArray= [[CoreDataModel sharedCoreDataModel] arrayOfRecordsForEntity:@"Location" andPredicate:[NSPredicate predicateWithFormat:@"%@",enumKey] andSortDescriptor:nil forContext:nil];
Problem: What should be my predicate which ensure that value "Pune" is matches with any attribute from "Location" ?
Kindly suggest NSPredicate value.
EIDT
NSString *enumKey = @"abc";
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Location" inManagedObjectContext:[[CoreDataModel sharedCoreDataModel] getNewManagedObjectContext]];//
NSMutableArray *orPredicateArray=[[NSMutableArray alloc] init];
for(NSDictionary *attributeName in entity.attributesByName) {
[orPredicateArray addObject:[NSPredicate predicateWithFormat:@"%K == %@",attributeName,enumKey]];
}
NSCompoundPredicate *combinedPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:orPredicateArray];
NSArray *enumKeyReferenceArray= [[CoreDataModel sharedCoreDataModel] arrayOfRecordsForEntity:@"Location" andPredicate:combinedPredicate andSortDescriptor:nil forContext:nil];
There is now "abc" value in any of attribute but still i am getting object for "Location" ?