Core data 核心数据是否绕过了安全性?

Core data 核心数据是否绕过了安全性?,core-data,nssecurecoding,Core Data,Nssecurecoding,我的iOS 13.2 Swift应用程序是一种SceneKit编辑器,它使用核心数据保存用户编辑。我想知道核心数据是否可能与下面的消息关联,因为NSManagedObject是NSObject的子类,而且我创建的没有核心数据的测试应用程序不会导致显示消息 虽然我没有对任何支持NSSecureCoding的SceneKit类进行子分类,并且应用程序中没有其他类使用NSSecureCoding,但当SCNcene显示在SCNView中时,将显示以下消息: 显示的消息: [general]NSSecu

我的iOS 13.2 Swift应用程序是一种SceneKit编辑器,它使用核心数据保存用户编辑。我想知道核心数据是否可能与下面的消息关联,因为NSManagedObject是NSObject的子类,而且我创建的没有核心数据的测试应用程序不会导致显示消息

虽然我没有对任何支持NSSecureCoding的SceneKit类进行子分类,并且应用程序中没有其他类使用NSSecureCoding,但当SCNcene显示在SCNView中时,将显示以下消息:

显示的消息:

[general]NSSecureCoding allowed classes列表包含[NSObject class],它通过允许隐式解码任何Objective-C类绕过安全性。考虑在解码过程中减少允许的类的范围,只列出要解码的类,或者比NSbase.</P>更具体的基类。
static func createNonCachedItemThumbnailData(item: Item) -> Data? {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        let dataSource = appDelegate.dataSource
        guard let selectedDesign = dataSource.selectedDesign else { return nil }
        let resourceSubdirectoryName = selectedDesign.uniqueID!
        guard let bundleURL = Bundle.main.url(forResource: item.uniqueID!, withExtension: "png", subdirectory: resourceSubdirectoryName + ".scnassets") else { return nil }
        guard let imageSource = CGImageSourceCreateWithURL(bundleURL as CFURL, nil) else { return nil }
        /*
        maxDimension is the lesser of the width or height of the UIImageView in ItemSCNNodeSelectionViewCell.
        */
        let maxDimension: CGFloat = 64.0
        let options: [NSString: Any] = [
            kCGImageSourceThumbnailMaxPixelSize: maxDimension,
            kCGImageSourceCreateThumbnailFromImageAlways: true]
        guard let scaledImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options as CFDictionary) else { return nil }

        return UIImage(cgImage: scaledImage).pngData()
    }
此消息仅显示一次,即使SCNScene可以多次重新打开以反映用户的编辑

可能原因 1.一些核心数据实体包含用于显示缩略图的二进制数据属性。但是,当我注释掉与创建/显示缩略图相关的代码时,仍会显示上述消息。缩略图数据是使用以下返回可选数据对象的代码创建的。我想知道这一点,因为Swift连接到NSData,后者是NSObject的一个子类

static func createNonCachedItemThumbnailData(item: Item) -> Data? {
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        let dataSource = appDelegate.dataSource
        guard let selectedDesign = dataSource.selectedDesign else { return nil }
        let resourceSubdirectoryName = selectedDesign.uniqueID!
        guard let bundleURL = Bundle.main.url(forResource: item.uniqueID!, withExtension: "png", subdirectory: resourceSubdirectoryName + ".scnassets") else { return nil }
        guard let imageSource = CGImageSourceCreateWithURL(bundleURL as CFURL, nil) else { return nil }
        /*
        maxDimension is the lesser of the width or height of the UIImageView in ItemSCNNodeSelectionViewCell.
        */
        let maxDimension: CGFloat = 64.0
        let options: [NSString: Any] = [
            kCGImageSourceThumbnailMaxPixelSize: maxDimension,
            kCGImageSourceCreateThumbnailFromImageAlways: true]
        guard let scaledImage = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options as CFDictionary) else { return nil }

        return UIImage(cgImage: scaledImage).pngData()
    }
  • 其中一个核心数据实体使用NSKeyedArchiver/NSKeyedUnachiver将SCN资料归档为二进制数据。我没有为此属性使用可转换类型,因为我了解到,在保存上下文时,可转换类型不会注意到更改。这段代码似乎与问题相去甚远,但编译器可能已经注意到了这一点
  • 任何帮助都将不胜感激