I am getting a EXC_BAD_ACCESS (SIGBUS) on this line in my iPhone project:
if (timeoutTimer) [timeoutTimer invalidate];
The thing that has me stumped is that I don’t understand how that line could crash, since the if statement is meant to be checking for nil. Am I misunderstanding the way Objective-C works, or do line numbers in crash statements sometime have the wrong line in them?
Just because a variable is set to a value other than
nildoesn’t mean it’s pointing to a valid object. For example:Your timer has probably already been gotten rid of (or possibly hasn’t been created at all?) but the variable wasn’t set to nil.