itzo itzo - 2 months ago 55
Objective-C Question

[UIDeviceRGBColor countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x16577e10 -> A Crash After makeKeyAndVisible

I get the following error when debug and found that after this line, the app crash:

[self.window makeKeyAndVisible];


When attempt to run on device via Xcode 8.0, the following error log appears:


2016-10-03 11:03:59.827994 Slots[5972:1125279] -[UIDeviceRGBColor
countByEnumeratingWithState:objects:count:]: unrecognized selector
sent to instance 0x16577e10

2016-10-03 11:03:59.830292 Slots[5972:1125279] *** Terminating app due
to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIDeviceRGBColor countByEnumeratingWithState:objects:count:]:
unrecognized selector sent to instance 0x16577e10'

* First throw call stack: (0x1db25e07 0x1cd8b077 0x1db2b515 0x1db29589 0x1da4ef08 0x2303d18d 0x23037bff 0x1e3b39a5 0x1e3b2e6d
0x23047fc9 0x23048641 0x1e3b39a5 0x1e3b9d3d 0x1e354ca7 0x1e3b39a5
0x1e3b2e6d 0x23047507 0x22ec2589 0x22c9eecb 0x22b6b067 0x22b6af9f
0x22b716a3 0x22b6eb9d 0x22be1051 0xc3cf1 0x22bdd33b 0x22de9e01
0x22def41f 0x22e01fc5 0x22dec805 0x1f3ea97b 0x1f3ea835 0x1f3eab1f
0x1dae1c8b 0x1dae1795 0x1dadfa6b 0x1da2f073 0x1da2ee81 0x22bd6b69
0x22bd1201 0xc398f 0x1d1fa50b)
**libc++abi.dylib: terminating with uncaught exception of type NSException



Any ideas what might be causing this crash. I have no storyboards, only xibs.

Answer

Same issue with iOS 10 and while loading view or initializing view from/or using xib's.

You can try following solution:

  1. Go to your interface files, means Xib's and Nib's.

  2. On the right side, navigate to the File Inspector tab.

  3. Change the value for "Build for" to "iOS 7.0 and Later" or any other iOS version and later.

  4. Clean, Rebuild and Run project.

Check image for reference:

enter image description here