Today, we room going to settle the most usual mistakes that civilization make once they’re brand-new to iOS development. This error takes location when we work-related withuser user interface while adding or deleting the elements. To make things much easier we are going to first replicate the error, then analyze and finally settle it.

You are watching: This class is not key value coding-compliant for the key

Ready? let’s go.

Class Not vital Value Coding Compliant

As you deserve to see I have twoIBOutlets in my watch Controller. The an initial IBOutlets is dubbed imageView1 i beg your pardon is precisely how we want to surname it but the second one I’ve accidentally spelled that wrong. Now the error happens when you try to solve it.

Instead of callingimage2,I’m going to speak to it imageView2. Also though everythinglooks good and I’ve resolved the order error over there is a problem. First indication that we made a wrong is the tiny circle top top the left side of theIBOutlet. Psychic that when the circle is filled link is active, yet now the one is empty and it’s not linked to anything.

Breaking The link To The Outlet

If we operation the app it will certainly crash as result of uncaught exception ‘NSUnknownKeyException’ i m sorry this is a an extremely common error in Xcode.

In the beginning,when you room debugging Xcode tasks it can be very complicated and frustrating to know error messages. However, end time, you’ll start getting used come those error codes and also what lock mean.

Understanding Error Message

Now the vital keyword in this error blog post is: “this class is not an essential value coding-compliant because that the crucial image2“. To translate this, Xcode is trying to tell united state that there to be something dubbed image2 i m sorry it deserve to no longer find. Our target is to figure out whereby does the key image2 come from, which us renamed in the see Controller.Now let’s go searching for this error.

By renaming the IBOutlet, we’ve actually broken the connection, since when we hover over the no much longer highlights the second image view yet that link is a piece of XML code that exists in Main.storyboard

Connections In The Storyboard

So if we open theMain.storyboardas resource Code friend will have the ability to see that we have actually two connection. Over there is one outlet calledimageView1 andthere’s another outlet which is dubbed image2. So since we haven’t damaged the link when us renamed the outlet it still continues to be in the storyboard and also causes our app to crash.

Fixing the Error

If we right-clickon the picture view, we have the right to see that thereis a reference outlet come the watch Controller with a vital called image2. Now we are going to rest that link by click the small cross button, which will alsoerase the password in the XML file.

Breaking relationships Using referencing Outlets

If you’re do the efforts to edit the IBOutlet, make certain that you very first delete any old connections with the outlet.

Now I can recreate a link to the newly called imageView2 in the same method that we produced the previous one. You host down the control vital on the image view and drag it over. The procedure might look contempt different due to the fact that we already have named the IBOutlet. So once you mouse over to the imageView2 it will certainly highlight the area in blue, which means that it web links it approximately this line of code.

Reconnecting one IBOutlet

Using the relations inspector

Another way to fix this error isto open the best side panel, then choose View Controller and also switch come the relationships inspector. Currently if girlfriend look closely at the relations inspector you have actually all the outlets listed. If you relocate the computer mouse at every outlet the will present you theUIElement the is connected with. ~ above the ideal side, if the period is filled then the link is properly established. However if it has actually an exclamation mark then other is wrong v this outlet and also it’s resulting in a problem.

Using The relations Inspector

You deserve to fix the error by breaking the link that is leading to the problem. Merely click the X to delete the outlet. Climate you deserve to go ago to the check out Controller and also simply recreate the connection. Just host the control an essential and drag and also drop the computer mouse pointer come the outlet you want to connect. You will an alert that the period on the appropriate side is filled-in again which way that everything is working.

Now if you select View Controller and also then open up up connections inspector you will view that there room no exclamation marks. Therefore the error is fixed and also you can run the app.

Congratulate! now your app won’t crash again.

See more: Lord Listen To Your Children Praying, Lord, Listen To Your Children (Satb ) By Ken


Even thought Xcode looks for this reason clean and straightforward there room lots of covert features and it takes time to find and learn every these things. For this reason whenever you obtain the error: “this class is not key value coding-compliant” girlfriend should very first and foremost think if girlfriend recently readjusted something that has actually a connection to the Main.storyboard or to the style file.

For the most time, there is one unbroken connection come something the no much longer exists in the code.


Enums In Swift Explained

Sometimes we need to produce our own data types for particular parts of our app. That’s wherein Enumerations come in handy. However what room the other benefits the Enum? The Swift Enum gives us the opportunity to version a certain variety of options, to do our codetype-safe,


For Loop In Swift Explained

Many times when you’re developing the App, friend will uncover yourself needing come repeat pieces of code. Because that instance, if we desire to publish “Hello World” five times, wecould merely writea print statementfive times. It will definitelyprint out


Arrays In Swift Explained

If you’re working with numerous pieces that data it would certainly be hard to control them with merely constants and variables. In that case, Arrays deserve to make our life easier. Carry out You want to learn How? Arrays are one of three collection varieties available in the Swift programming to