在上下文保存期间,我遇到了一些特殊情况(并不总是)这个错误:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x248adf8f 0x331fac8b 0x247c07a5 0x2466eccd 0x2466deb5 0x245da5eb 0x245d98a9 0x245a7b25 0x246599c5 0x246619a3 0x190d15f 0x1914ea5 0x24653f1d 0x245a7703 0x245c97d1 0x26ba9c 0x230a08 0x269560 0x26b65c 0x1b4580 0x1b35f0 0x65b51c 0x6595cc 0x658258 0x617d18 0x190d173 0x190d15f 0x1910e45 0x248733e9 0x24871ae9 0x247bdf31 0x247bdd43 0x2c298201 0x27f8f879 0x24dc1c 0x337acaaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
代码:
do {
try context.save()
} catch let error as NSError {
debugPrint(error)
debugPrint(error.userInfo)
}
你知道什么可能导致错误以及如何修复它?
谢谢。