我試圖在NSPredicate中使用IN子句。我收到以下錯誤:Swift核心數據謂詞IN子句
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0xa000000000000611'
下面的代碼:
let fetchRequest: NSFetchRequest<Employee> = NSFetchRequest(entityName: "Employee")
fetchRequest.sortDescriptors = [
NSSortDescriptor.init(key: "lastName", ascending: true)
]
fetchRequest.predicate = NSPredicate(format: "ANY id IN %@", argumentArray: recentEmployeeIds)
fetchedResultsController = NSFetchedResultsController.init(fetchRequest: fetchRequest,
managedObjectContext: FLCoreDataController.shared.mainObjectContext,
sectionNameKeyPath: nil,
cacheName: nil)
fetchedResultsController?.delegate = self
try? fetchedResultsController?.performFetch()
任何想法的問題是什麼?
刪除'argumentArray無標籤:'標籤。你只傳遞一個參數給你的謂詞(這是一個數組),而不是一個參數數組。 – dan
這工作!非常感謝你的幫助。 –