美文网首页
Swift报错this class is not key val

Swift报错this class is not key val

作者: 小呀小苹果呀 | 来源:发表于2019-06-27 18:10 被阅读0次

记录一个日常开发遇到的问题:
定义了一个数据model,继承自NSObject,在Swift中使用model.value(forKey: "key1")时闪退,报错:this class is not key value coding-compliant for the key


image.png

解决方法:
KVC是OC的特性,只继承自NSObject是不够的,还要加上@objcMembers关键字


image.png

相关文章

网友评论

      本文标题:Swift报错this class is not key val

      本文链接:https://www.haomeiwen.com/subject/idxdcctx.html