【发布时间】:2018-02-27 02:41:17
【问题描述】:
我有一个简单的两个实体核心数据数据库 实体 1 - 属性 1 - 属性 2 实体 2 - 属性 1
定义了关系,因此对于每个实体 1,我可以拥有许多实体 2。
我选择了一个实体 1 - 通过 UITableView 我现在想检索所有 Entity 2 记录。我正在尝试使用 NSPredicate,但这似乎是错误的方式。这是代码 - 它不能为 NSPredicate 调用初始化:
lazy var entity2Predicate: NSPredicate = { return NSPredicate(format: "%K = %@", #keyPath(Entity1.relationship), ascending: true)}()
为与 Entity1 相关的所有 Entity2 记录定义提取的正确方法是什么?
【问题讨论】: