发生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,以便连续使用这些数据。