从iOS 12版的核心数据崩溃中获取数据

时间:2018-12-05 11:23:45

标签: swift core-data

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

  

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

以下崩溃的崩溃报告:-

  

崩溃:com.apple.root.user-initiated-qos                       0 libobjc.A.dylib 0x1edc58d70 objc_msg发送+ 16                       1个CoreData 0x1f16b653c _PF_Handler_Public_GetProperty + 252                       2基础0x1ef41c3cc-[NSFunctionExpression expressionExpressionValueWithObject:context:] + 808                       3基础0x1ef41bfc8-[NSComparisonPredicatevaluateWithObject:substitutionVariables:] + 228                       4 CoreData 0x1f1590e8c-[NSManagedObjectContext executeFetchRequest:error:] + 3476                       5 Quickride 0x1044f6d28专用静态   NotificationPersistenceHelper.isNotificationAlreadyPresent(uniqueId :)   (NotificationPersistenceHelper.swift:284)                       6 Quickride 0x104465c4c专门的NotificationHandler.saveNotification(clientNotification :)   (NotificationHandler.swift:58)                       7 Quickride 0x1047174c8 AppStartupHandler.sessionChangeOperationCompleted()   (NotificationStore.swift:26)                       8 Quickride 0x104718058协议见证   中的SessionChangeCompletionListener.sessionChangeOperationCompleted()   一致性AppStartupHandler(AppStartupHandler.swift)                       9 Quickride 0x10479f4b0 SessionManagerController.notifyListenerAboutSessionChangeOpCompletion()   (SessionManagerController.swift:284)                       10 Quickride 0x10479e638 SessionManagerController.resumeUserSession(sessionChangeCompletionListener :)   (SessionManagerController.swift:93)                       11 Quickride 0x1047170c8封闭#1 in   AppStartupHandler.resumeUserSessionAndNavigateToAppropriateInitialView()   (AppStartupHandler.swift:38)                       12 Quickride 0x104371784对@callee_owned()->()进行了修改   (RideManagementModuleSessonHandler.swift)                       13 libdispatch.dylib 0x1ee4a96c8 _dispatch_call_block_and_release + 24                       14 libdispatch.dylib 0x1ee4aa484 _dispatch_client_callout + 16                       15 libdispatch.dylib 0x1ee459b5c _dispatch_root_queue_drain + 684                       16 libdispatch.dylib 0x1ee45a2d0 _dispatch_worker_thread2 + 128                       17 libsystem_pthread.dylib 0x1ee68c17c _pthread_wqthread + 472                       18 libsystem_pthread.dylib 0x1ee68ecec start_wqthread + 4

发生崩溃的部分代码,此代码在iOS版本12之前可以正常使用:-

                static func isNotificationAlreadyPresent(uniqueId :Double?) -> Bool{
                        if uniqueId == nil{
                            return false
                        }

                        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{
                        }
                        return false
                    }

            Crash occurred at below line :-

            let results = try managedContext.fetch(fetchRequest)

上面的从核心数据中获取数据的代码在iOS版本11之前运行良好,但是现在对于使用iOS版本12的用户而言,此崩溃发生了。

您能帮我解决此崩溃问题,想知道为什么这只会给版本12带来麻烦吗,是否还有其他特定于iOS版本12的方法来获取核心数据,或者iOS版本本身存在问题?如果有什么解决方案?

我在过去2天中搜索此内容并无法理解为什么它仅崩溃到iOS版本12。请任何人帮助我解决此崩溃。

预先感谢

0 个答案:

没有答案