0

I get the error when trying to change the title on a button

btnStop.setTitle("Stop", forState: UIControlState.Normal)

gives out the error: (exc_bad_instruction exc_i386_invop, subcode 0x0)

is there another way to set the title of the button? or what am I doing wrong? the btnStop variable is a global one, so I don't see why it has an issue - as it doesn't have this issue on my iPhone?

2 Answers2

1

I was stymied by the same situation: every time I tried to set the title of a particular button I got the exact error you received. It turns out the problem was not with the UIButton at all, but rather the use of arc4random() with type casting later on within the code block. Doesn't make sense, I know; probably a beta bug in swift just showing the crash on the wrong line; but here's the reference to the solution that got me running again: Crash when casting the result of arc4random() to Int

Community
  • 1
  • 1
0

Since this is Swift and a beta Xcode, there is always the possibility of a tools bug. Presuming that there is a bug in your code, I would run the Zombies instrument and see if you are accessing an over-released object.

Even with ARC, this can still happen. Are you possibly using weak references somewhere to avoid a reference cycle?

Also, in my experience, exc_bad_instruction is often the result of an assertion-like call in Apple code (they purposely put in a bad instruction to cause a crash) and is accompanied by some explanation. Can you paste in the full error with stack trace.

Lou Franco
  • 87,846
  • 14
  • 132
  • 192