Cannot decode object of class

后端 未结 5 1672
难免孤独
难免孤独 2020-12-08 04:54


I am trying to send a \"Class\" to my Watchkit extension but I get this error.

* Terminating app due to uncaught exception \'NSInvalidUna

5条回答
  •  被撕碎了的回忆
    2020-12-08 05:19

    I had to add the following lines after setting up the framework to make the NSKeyedUnarchiver work properly.

    Before unarchiving:

    NSKeyedUnarchiver.setClass(YourClassName.self, forClassName: "YourClassName")
    

    Before archiving:

    NSKeyedArchiver.setClassName("YourClassName", forClass: YourClassName.self)
    

提交回复
热议问题