ios - "CoreData: error: NULL _cd_rawData but the object is not being turned into a fault"

标签 ios swift core-data

这是发生错误时的代码部分:

class func randomWord() -> TBWord {

    let randomIndex = Int(arc4random_uniform(UInt32(TBAppSettings.wordsForCurrentGame.count)))
    let word = TBAppSettings.wordsForCurrentGame[randomIndex]

    TBAppSettings.wordsForCurrentGame.removeAtIndex(randomIndex)

    MagicalRecord.saveWithBlock { context in

        let word = TBWord.findWordWithIdentifier(word.identifier, inContext: context) //here error happens
        word?.used = true
    }

    return word
}

我该如何解决这个问题?我知道关于这个问题的其他问题,但它们对我来说还不够。

最佳答案

(除此之外,MagicalRecord 是对如何正确使用 Core Data 的一个很大的误解......)

您是否尝试过使用 -com.apple.CoreData.ConcurrencyDebug 1 作为启动参数来运行代码?这听起来像是线程问题。

关于ios - "CoreData: error: NULL _cd_rawData but the object is not being turned into a fault",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34550694/

相关文章:

cocoa - 在可转换的核心数据属性上使用系统提供的 NSValueTransformer

ios - 如何使用 MonoTouch AudioConverter 将 LinearPCM 转换为压缩格式?

ios - xcode 5 水平 ScrollView 不工作 (iOS7)

iphone - Cocos2D标签不可见,黑屏

swift - 从 "Start"时间计算 "End"时间

iOS 为什么我的 UIPickerview 方法循环?

ios - ARKit仅检测地板来放置物体

swift - iPad Pro Measure App 如何计算人的高度?

ios - Swift 中带有核心动画的动画 UILabel 元素

ios - 如何使用核心数据在数据库中仅添加单个值?