gpt4 book ai didi

ios - swift 3 : -[_SwiftValue mergeType]: unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-12-01 16:08:56 26 4
gpt4 key购买 nike

每当我在删除或更新记录后尝试保存托管对象上下文时,都会收到“-[_SwiftValue mergeType]: unrecognized selector sent to instance”错误。例如:

context.delete(managedObject)

遵从
context.save()

是的,context.save() 正在 try catch 。

记录插入就好了,但删除会引发异常。堆栈跟踪如下:
*** 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

跟踪在离开我的代码后立即开始。

任何见解都会有所帮助。

最佳答案

当您使用这样的代码来设置合并策略时,您可能会收到此错误:

context.mergePolicy = NSMergePolicyType.mergeByPropertyStoreTrumpMergePolicyType

而是使用这个:
context.mergePolicy = NSMergePolicy(merge: .mergeByPropertyStoreTrumpMergePolicyType)

关于ios - swift 3 : -[_SwiftValue mergeType]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40554616/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com