首页 > 解决方案 > 核心数据:无法识别的选择器发送到实例错误

问题描述

我正在尝试将自定义类保存到核心数据中,但出现此错误

2019-01-07 16:58:25.147183-0600 flashcard![21075:2906968] [error] error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x2808f4780> , -[flashcard_.Card encodeWithCoder:]: unrecognized selector sent to instance 0x2837aefd0 with userInfo of (null)
CoreData: error: SQLCore dispatchRequest: exception handling request: <NSSQLSaveChangesRequestContext: 0x2808f4780> , -[flashcard_.Card encodeWithCoder:]: unrecognized selector sent to instance 0x2837aefd0 with userInfo of (null)
2019-01-07 16:58:25.149540-0600 flashcard![21075:2906968] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[flashcard_.Card encodeWithCoder:]: unrecognized selector sent to instance 0x2837aefd0'

当我尝试保存上下文时。我不知道我在这里做错了什么。

@IBAction func studyPressed(_ sender: Any) {



        var deck = Decks(context: context)
        deck.name = deckNameInput.text!
        deck.cards = cardArray


        if(deckNameInput.text != "" && deckNameInput.text != "ex: physchology 101"){

            do {
                try ad.saveContext()

            } catch {

            }
        }

    }

标签: swiftcore-data

解决方案


推荐阅读