"Location"エンティティと "Location"エンティティというエンティティのコードデータには、約50の属性があります。iOS:チェック値がコアデータ内のエンティティの属性と一致していますか?
私は与えられた値を確認するには、次の述語を使用するには、「場所」の実体(私は任意の特定の属性が、エンティティからのすべての属性でそれを一致させる必要はありません)
NSString *[email protected]"Pune";
NSArray *enumListForDeleteArray= [[CoreDataModel sharedCoreDataModel] arrayOfRecordsForEntity:@"Location" andPredicate:[NSPredicate predicateWithFormat:@"%@",enumKey] andSortDescriptor:nil forContext:nil];
問題から任意の属性と一致します。どのような値 "Pune"が "Location"の属性と一致することを保証する私の述語でなければなりませんか?
NSPredicateの値を推奨します。
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];
あり、「ABC」の値は、属性のいずれかになりましたが、それでも私は「場所」のためのオブジェクトを取得していますか?
@Larme。回答ありがとうございますが、私はどのエンティティのすべての属性と比較する単一の述語を見つけませんでした。 –