我将一个旧项目从 Swift 1 转换为使用 CoreData 的 Swift 4.2(在主要版本步骤中,全部成功构建)。
现在编译器在尝试执行此代码时会抛出以下错误:
let sortDescriptor = NSSortDescriptor(key: "dateModified", ascending: false)
let predicate = NSPredicate(format: "markAsDeleted == false")
if let itemInspections = item.inspections?.filtered(using: predicate).sortedArray(using: [sortDescriptor]) {
label.text = "Items (\(itemInspections.count))"
}
错误:
2018-09-25 17:19:06.606722+0200 AppName[538:144354]-[_NSFaultingMutableSet filteredOrderedSetUsingPredicate:]:无法识别的选择器发送到实例 0x17063afc0 2018-09-25 17:19:06.607861+0204 * AppName:1453] ** 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[_NSFaultingMutableSet filteredOrderedSetUsingPredicate:]: unrecognized selector sent to instance 0x17063afc0”
*** First throw call stack: (0x18f5d6fd8 0x18e038538 0x18f5ddef4 0x18f5daf4c 0x18f4d6d2c 0x100126ce0 0x10015fa10 0x10015fc18 0x195ff9268 0x19575f884 0x19575a4ac 0x1956fc158 0x1928ec274 0x1928e0de8 0x1928e0ca8 0x19285c360 0x1928833c0 0x1956f17a0 0x18f5849a0 0x18f582628 0x18f582a74 0x18f4b2d94 0x190f1c074 0x195764130 0x100110cb4 0x18e4c159c)
libc++abi.dylib:以 NSException 类型的未捕获异常终止
任何指针将不胜感激。