Unrecognized selector UIDeviceRGBColor countByEnumeratingWithState:objects:count:

孤人 提交于 2019-12-04 23:40:52

When I try to compile and run my project with the same configuration (XCode 8 beta 6, iOS 10 SDK), I encountered a similar issue, except that my error message was:

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

And I noticed that this issue only occurs when the view is init by using interface files, i.e. Xib and Nib. I solved this issue by:

  1. Open your interface file, in the right panel, navigate to the File Inspector tab.

  2. Change the attribute highlighted to "iOS 7.0 and Later" (or whatever iOS version later)

Then compile and run your project again, this should fix your issue, though I am not sure about the reason behind this. I tried the same with your sample project and it solves the issue too.

In my case, I needed to change the project deployment target to 8.0 in the product general settings. Thanks to the hint from the accepted answer!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!