核心数据崩溃获取

时间:2018-12-04 04:24:14

标签: ios swift core-data

以下是崩溃报告中的内容:-

致命异常:NSInvalidArgumentException -[_ PFFetchPlanHeader _genericValueForKey:withIndex:flags:]:无法识别的选择器已发送到实例0x282b24730

发生崩溃的代码部分:-

    let managedContext = CoreDataHelper.getNSMangedObjectContext()
    let fetchRequest = NSFetchRequest<NSFetchRequestResult>(entityName: NotificationPersistenceHelper.UserNotification_entity)
    fetchRequest.predicate = NSPredicate(format: "\(NotificationPersistenceHelper.uniqueID) = %@", argumentArray: [uniqueId!])
    do{
         let results = try managedContext.fetch(fetchRequest)

        return  !results.isEmpty
    }catch let error as NSError{
        AppDelegate.getAppDelegate().log.error("Fetch Failed : \(error.localizedDescription)")
    }
    return false

崩溃是从上述代码的以下行发生的:-

  let results = try managedContext.fetch(fetchRequest)

有关崩溃发生原因的任何帮助,人们进行了很多尝试,但未能找到崩溃的原因。有任何帮助吗?....提前谢谢

1 个答案:

答案 0 :(得分:1)

代替此

fetchRequest.predicate = NSPredicate(format: "\(NotificationPersistenceHelper.uniqueID) = %@", argumentArray: [uniqueId!])

尝试这个

fetchRequest.predicate = NSPredicate(format: "%K == %@", #keyPath(NotificationPersistenceHelper.uniqueID), uniqueId!)