0

发生未知错误NSKeyedUnarchiveWithObjectWithData

我曾经在我的项目NSKeydArchiver中存档一个[NSIndexPath:UIColor]字典,NSData但是当我在我的 XCode 和 iOS 模拟器中构建项目时发生错误。

然后,当我尝试任何无法构建的 iOS 模拟器时。我什至通过 git 更改了分支并构建它,出现同样的问题。

但是当我生成 IPA 文件并将其安装到我的 iPhone 中时,构建应用程序没有问题。

这是错误和源代码。有人有这方面的经验吗?

“unarchiveObjectWithData:”线程 1:EXC_BAD_INSTRUCTION(代码=EXC_I386_INVOP,子代码=0x0)

    let data = self.ud.objectForKey("data") as? NSData
    if let _ = colorData {
        colorDictionary = NSKeyedUnarchiver.unarchiveObjectWithData(data!) as! [NSIndexPath:UIColor]
    }
    if !colorDictionary.isEmpty {
        for (indexPath, color) in colorDictionary {
            self.collectionView.cellForItemAtIndexPath(indexPath)?.backgroundColor = color
        }
    }

有一个 NSUserDefaults ,我将 [NSIndexPath:UIColor] 字典保存到 NSUserDefaults 以便连续使用数据。

4

0 回答 0