核心数据:无法识别的选择器发送到实例错误

时间:2019-01-07 22:59:58

标签: swift core-data

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

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 {

            }
        }

    }

0 个答案:

没有答案