Core Data predicate : unimplemented SQL generation for predicate

前端 未结 5 1467
旧巷少年郎
旧巷少年郎 2020-12-09 10:50

Basically I got 3 entities in my data model : Brand, Model and Trim.

  • A brand has a one-to-many relationship with Model called \"models\". (one brand have multi
5条回答
  •  误落风尘
    2020-12-09 11:15

    When you use a predicate in a CoreData operation, the predicate gets translated into SQL. That translation is not possible for all NSPredicate operations, you've hit one that isn't. My suggestion would be something along the lines of:

    NSMutableArray* predicates = [NSMutableArray new];
    for(NSString* trim in arrayOfTrims)
    {
        [predicates addObject:[NSPredicate predicateWithFormat:@"%@ IN models.trims", trim]];
    }
    NSPredicate*    predicate = [NSCompoundPredicate orPredicateWithSubpredicates:predicates];
    

提交回复
热议问题