简体   繁体   English

Swift 3:-[_SwiftValue mergeType]:无法识别的选择器发送到实例

[英]Swift 3: -[_SwiftValue mergeType]: unrecognized selector sent to instance

I am getting a '-[_SwiftValue mergeType]: unrecognized selector sent to instance' error whenever I try to save a managed object context after doing a delete or an update of a record.每当我在删除或更新记录后尝试保存托管对象上下文时,都会收到“-[_SwiftValue mergeType]: unrecognized selector sent to instance”错误。 For example:例如:

context.delete(managedObject)

follow by跟随

context.save()

and yes, context.save() is in a do-try-catch.是的,context.save() 正在尝试捕获。

Records insert just fine, but the delete is throwing an exception.记录插入就好了,但删除会引发异常。 Stack trace is as follows:堆栈跟踪如下:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_SwiftValue mergeType]: unrecognized selector sent to instance 0x60800005b0f0'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010afac34b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000010a5f021e objc_exception_throw + 48
    2   CoreFoundation                      0x000000010b01bf34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   CoreFoundation                      0x000000010af31c15 ___forwarding___ + 1013
    4   CoreFoundation                      0x000000010af31798 _CF_forwarding_prep_0 + 120
    5   CoreData                            0x000000010aae203a -[NSManagedObjectContext(_NSInternalAdditions) _validateObjects:forOperation:error:exhaustive:forSave:] + 1946
    6   CoreData                            0x000000010aae1836 -[NSManagedObjectContext(_NSInternalAdditions) _validateChangesForSave:] + 422
    7   CoreData                            0x000000010aae1476 -[NSManagedObjectContext(_NSInternalChangeProcessing) _prepareForPushChanges:] + 214
    8   CoreData                            0x000000010aaddeb2 -[NSManagedObjectContext save:] + 562

Trace starts right after it leaves my code.跟踪在离开我的代码后立即开始。

Any insight would be helpful.任何见解都会有所帮助。

You may get this error when you use code like this, to set a merge policy:当您使用这样的代码来设置合并策略时,您可能会收到此错误:

context.mergePolicy = NSMergePolicyType.mergeByPropertyStoreTrumpMergePolicyType

Instead use this:而是使用这个:

context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyStoreTrumpMergePolicyType)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift 3 错误:[_SwiftValue pointSize] 无法识别的选择器发送到实例 - Swift 3 error: [_SwiftValue pointSize] unrecognized selector sent to instance [__SwiftValue encodeWithCoder:]:无法识别的选择器发送到实例 - [__SwiftValue encodeWithCoder:]: unrecognized selector sent to instance -[_ SwiftValue encodeWithCoder:]:无法识别的选择器已发送到实例 - -[_SwiftValue encodeWithCoder:]: unrecognized selector sent to instance 未捕获的异常'NSInvalidArgumentException',原因: - [_ SwiftValue floatValue]:无法识别的选择器发送到实例 - Uncaught exception 'NSInvalidArgumentException', reason: -[_SwiftValue floatValue]: unrecognized selector sent to instance Swift无法识别的选择器已发送到实例 - Swift unrecognized selector sent to instance Swift:发送到实例的无法识别的选择器 - Swift: unrecognized selector sent to instance Swift-无法识别的选择器已发送至实例 - Swift - unrecognized selector sent to instance 使用 [__SwiftValue set] 将 AppDelegate 从 Objective-C 转换为 Swift 后,应用程序在每个 segue 上崩溃:无法识别的选择器发送到实例 - App crash on every segue after converting AppDelegate to Swift from Objective-C with [__SwiftValue set]: unrecognized selector sent to instance 无法识别的选择器发送到Swift中的实例? - unrecognized selector sent to instance in Swift? 无法识别的选择器已发送至实例-Swift 3 - unrecognized selector sent to instance - Swift 3
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM