shmiki shmiki - 1 year ago 123
Swift Question

What does it mean thread 1 exc_bad_instruction (code=exc_i386_invop subcode=0x0)

enter image description here

I got this problem when I tried to delegate scores from


enter image description here

It works normally if I remove

Answer Source

The first time you run your app there will be no values in UserDefaults.

This means that in viewDidLoad, the call to:


will return a nil value. But you are assigning the result to a non-optional variable.

Change the line to:

if let name = UserDefaults.standard.string(forKey:"bestName") {
    bestName = name

There is no problem with the call to integer(forKey:) because it returns 0 if there is no existing value.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download