*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber length]: unrecognized selector sent to instance

 

网上参考的他人案例,与我的情况一模一样,所以直接盗用他的图和文章了。

http://www.tuicool.com/articles/EZ3uMb7

 

iOS开发——异常:[__NSCFNumber length]: unrecognized selector sent to instance

 

 iOS开发——异常:[__NSCFNumber length]: unrecognized selector sent to instance

 

这个错误是作者解析pilst文件中的字段的 comments数据类型为NSNumber类型,而在字典转模型时写成了NSString类型,所以报了以上错误;

 

iOS开发——异常:[__NSCFNumber length]: unrecognized selector sent to instance

 iOS开发——异常:[__NSCFNumber length]: unrecognized selector sent to instance

 

 

解决方法:
将模型属性中的comments改为NSNumber类型,掉用的时候做一下数据转换
设置属性类型为NSNumber
调用时做下数据类型转换,转成NSString即可

 

 

相关文章:

  • 2021-04-21
  • 2022-12-23
  • 2021-10-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2022-01-07
  • 2022-12-23
相关资源
相似解决方案