该类可以在源代码中定义,也可以在未链接的库中定义

时间:2018-05-15 10:43:05

标签: ios swift realm imessage

我已将AppDelegate上的 MLSData 设置为

func getMLSBoards() {
    Service.shared.getMlsBoards(completion: { (mlsResponse) in

        if mlsResponse?.respCode == Code.success.rawValue {
            Defaults.shared.setMLSBoards((mlsResponse?.data?.mlsBoard)!, forKey: Default.mlsBoards)

            for mlsBoard in (mlsResponse?.data?.mlsBoard)! {
                if mlsBoard.id == 1 {
                    Defaults.shared.setInt(mlsBoard.id!, forKey: Constants.kProviderID)
                    Defaults.shared.setString(mlsBoard.title!, forKey: Constants.kProviderValue)
                    Defaults.shared.setMLSBoard(mlsBoard, forKey: Default.mlsBoard)
                }
            }

            NotificationCenter.default.post(name: NSNotification.Name.init(Notifications.nReceivedMetadata), object: nil)
        }
    })
}

我希望在 iMessage APP

上获得 MLSData
let mlsBoard = Defaults.shared.getMLSBoards(forKey: Default.mlsBoards)

但我的应用程序因此消息而崩溃

  

由于未捕获的异常而终止应用   ' NSInvalidUnarchiveOperationException',原因:' ***    - [NSKeyedUnarchiver decodeObjectForKey:]:无法解码类(Sarnail.MlsBoard)的对象(NS.objects);班级可能是   在源代码中定义或未链接的库

我也试过这个

NSKeyedArchiver.setClassName("Employee", forClass: Employee.self)
NSKeyedUnarchiver.setClass(Employee.self, for: "Employee")

但它不适合我 有人请帮助我!

0 个答案:

没有答案