错误:-[UIImage _deleteExternalReferenceFromPermanentLocation] 无法识别的选择器发送到实例
当我删除包含图像(作为可转换值存储在外部记录中)的托管对象时,出现崩溃并出现以下错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage _deleteExternalReferenceFromPermanentLocation]: unrecognized selector sent to instance 0xde49360'
When I delete a managed object that contains image, stored as transformable value in external record, then I got crash and this error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage _deleteExternalReferenceFromPermanentLocation]: unrecognized selector sent to instance 0xde49360'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我在 Apple 开发者论坛中回答了类似的问题。
我猜您在数据建模器中的该字段上选中了外部存储复选框。
有一个错误可以解决。我是这样做的:
更新数据并保存上下文后,任何删除它的尝试都会引发此“无法识别的选择器”异常。
要强制使用可以响应 _deleteExternalReferenceFromPermanentLocation 消息的正确对象,请执行以下操作:
对象变成故障。当您下次访问或删除它时,外部数据将按预期删除,因为包装外部数据的正确对象将从存储中提取,并将正确响应 _deleteExternalReferenceFromPermanentLocation。
I answered to something similar in the Apple Developer forums.
I am guessing you have the external storage checkbox selected on that field in the data modeller.
There is a bug in that can be worked around. I did it like this:
Once you have updated your data, and saved the context, any attempt to delete it will raise this 'unrecognized selector' exception.
To force the correct object that can respond to the _deleteExternalReferenceFromPermanentLocation message, do this:
The object turns into a fault. When you next access it, or delete it, the external data is deleted as expected as the correct object that wraps your external data will be pulled from the store and will correctly respond to _deleteExternalReferenceFromPermanentLocation.
这意味着 UIImage 不响应:
...选择器,这意味着 UIImage 不实现该特定方法。这似乎是 Core Data 用于在外部文件中存储大量数据的私有方法之一。这是一个仅在 iOS 5 中可用的功能。
在这种情况下,有两个最可能的原因:
(1) 您将 UIImage 对象与托管对象混淆了,反之亦然,使得用于一个类的消息被发送到另一个类(即是此类错误的最常见原因。)
(2) 您尝试在模拟器或设备中的早期 iOS 下运行为 iOS 5 编译的代码。
The means that UIImage does not respond to the:
…selector which means that UIImage doesn't implement that particular method. This appears to be one of the private methods that Core Data uses to store large chunks of data in external files. That's a function only available in iOS 5.
In this case there are two most likely causes:
(1) You've confused a UIImage object with a managed object or vice versa such that a message intended for one class is sent to another (that is the most common cause of this class of error.)
(2) You trying to run code compiled for iOS 5 under an earlier iOS either in the simulator or the device.
我也遇到了这个问题,使用
NSDate
核心数据属性。我不需要将其存储在外部,但找不到任何要取消设置的复选框(Xcode 4.2)。然而,当我确认它时,它显然就在那里:所以我只是删除并重新创建了具有相同名称的该属性。
allowsExternalBinaryDataStorage
XML 属性消失了,我的崩溃也消失了。我一定是在 iOS 5 测试版或其他版本期间无意中检查了一些东西,它只是卡在数据模型中,静静地等待,直到我尝试删除一个对象。不管怎样,也许这会帮助其他遇到 iOS bug 但不需要将相关属性存储在外部的人。
I ran into this issue, too, with an
NSDate
core data attribute. I don't need it to be stored externally, but could not find any checkbox to unset (Xcode 4.2). However, it was clearly there when Iack
ed for it:So I just deleted and re-created that attribute with the same name. The
allowsExternalBinaryDataStorage
XML attribute went away and so did my crash. I must've inadvertently checked something during a beta release of iOS 5 or something and it just got stuck in the data model, quietly waiting until I tried to delete an object.Anyway, perhaps this will help other folks who run into what appears to be an iOS bug but don't need the attribute in question to be stored externally.