核心数据崩溃获取

核心数据崩溃获取

本文介绍了核心数据崩溃获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Here is the what the crash report says :-

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

Fatal Exception: NSInvalidArgumentException-[_PFFetchPlanHeader _genericValueForKey:withIndex:flags:]: unrecognized selector sent to instance 0x282b24730

发生崩溃的代码部分:-

The part of the code where the crash is happening :-

    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

崩溃我发生在上述代码的以下行中:-

the crash is happening at the following line from the above code:-

  let results = try managedContext.fetch(fetchRequest)

关于崩溃发生原因的任何帮助,人们付出了很多尝试,但未能找到崩溃的原因。有任何帮助人员吗?....在此先谢谢

Any help on why the crash is happening guys tried a lot but was not able to find the reason for the crash. Any help guys?.... Thanks in advance

推荐答案

代替此

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

尝试这个

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

这篇关于核心数据崩溃获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 12:49