william205
william205

Reputation: 688

xcode terminating app due to uncaught exception

I have made an app in xcode and whenever I build or run the app it says there are no issues but then after the launch image displays the app seems to crash and throw up this error.

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key high_score_outlet.' * First throw call stack: (0x1c24012 0x1609e7e 0x1cacfb1 0xcae41 0x4c5f8 0x4c0e7 0x76b58 0x619019 0x161d663 0x1c1f45a 0x617b1c 0x6198da 0x3fb68b 0x3fb9a2 0x3fa876 0x40bcb5 0x40cbeb 0x3fe698 0x255fdf9 0x255fad0 0x1b99bf5 0x1b99962 0x1bcabb6 0x1bc9f44 0x1bc9e1b 0x3fa17a 0x3fbffc 0x211d 0x2055) libc++abi.dylib: terminate called throwing an exception

I am not quite sure why it is crashing because it says that there are no issues in the code when building or running the app.

Any ideas how to fix it?

Upvotes: 0

Views: 782

Answers (3)

Paul.s
Paul.s

Reputation: 38728

It is most likely an IBOutlet that has gotten out of date.

Go to the first controller that will be loaded in your storyboard and check out the Connections Inspector (⌥⌘6) and look for an outlet connected to high_score_outlet.

enter image description here

This may be left over from an earlier refactoring. You'll want to disconnect it and set up the correct connection

Upvotes: 3

Kekoa
Kekoa

Reputation: 28230

You may have renamed your properties and forgot to reconnect the IBOutlet to your component in the Interface Builder file. Whenever you change a property in code that is an IBOutlet, you should check Interface Builder and reconnect that item if the connection was broken.

Your app will compile just fine because Interface Builder Outlets are connected at runtime, when the nib is being loaded.

Upvotes: 3

Rich Tolley
Rich Tolley

Reputation: 3842

Check whichever class has the property -high_score_outlet. The message you're getting means that the runtime can't find the relevant property implementation, so either:

  1. you haven't defined it correctly in the class, or
  2. you are calling it on an object that isn't the class you think it is. Use the debugger to verify the class of the object on which the method is being called.

Upvotes: 0

Related Questions