Xcode – How to fix ‘NSUnknownKeyException’, reason: … this class is not key value coding-compliant for the key X” error?

You may have a bad connection in your xib.

I’ve had this error many times. While TechZen’s answer is absolutely right in this case, another common cause is when you change the name of a IBOutlet property in your .h/.m which you’ve already connected up to File’s Owner in the nib.

From your nib:

  1. Select the object in IB and go to the ‘Connections Inspector’.
  2. Under ‘Referencing Outlets’ make sure that your object isn’t still connected to the old property name… if it is, click the small ‘x’ to delete the reference and build again.

    enter image description here

Another common cause if you are using Storyboard, your UIButton might have more then one assignings (Solution is almost the same as for nib):

  1. Open your storyboard and right click the UIButton
  2. You will see that there is more than one assign/ref to this button.
    Remove one of the “Main…” greyed windows with the small “x”:

    example 2

Leave a Comment