justinium justinium - 1 year ago 67
Swift Question

Receiving Thread 1 error related to IF statement

I understand this is a common error but I can't figure out why I am receiving it:

Thread 1 EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

enter image description here

Is there something specifically wrong with my code? To give some context the code is trying to determine if a particular item is on special and if it is then it strikes out the item's previous price that is displayed in the view controller.

Answer Source

You need to make sure globalVariable.previous and globalVariable.specialBool have the same count. Otherwise, the access to globalVariable.specialBool will crash.

Additionally, while i <= xxxx probably needs to be changed to while i < xxxx because array index is zero based.

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