Well I had an app I was developing in iPhone SDK 2.2 and I recently built and launched it in the 3.0 simulator. The base SDK is still set to 2.2. I figured that would avoid issues. Instead I get
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000a1b1c1f3
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x92f4b688 objc_msgSend + 24
1 Foundation 0x305085bd -[NSCFString isEqualToString:] + 61
2 HappyApp 0x00002c27 -[CombinationsTableViewController loadData] + 220 (CombinationsTableViewController.m:64)
The crash is occurring on a very simple line, where total
is a UITextField
if (![total.text isEqualToString:@""] ) {
Has anyone encountered this? I feel like it's a thread contention issue, or my whole app isn't compiling correctly. It works in the 2.2.1 simulator. If this turns out not to be the way to test a 2.2 app in OS 3.0, then what should I be doing other than switching that drop down box?
Update: Andrew Pouliot was right in that this was a released reference issue. The debugger was pointing one line off so I got the wrong hints. The culprit was actually this first line:
if(!([total.text isEqual:totalTextCache]
&& [divisions.text isEqual:divisionsTextCache])) {
//Loads the data for the table only if the values were actually changed
totalTextCache = total.text; //ditto for divisions
}
These lines are the only uses of totalTextCache
, and it became invalid if total.text
was changed.
This never caused a problem in the 2.2.1 sim probably because the old total.text
was never released by the runtime when it changed value. But this code was wrong. I fixed it by changing it to do exactly what I thought isEqual was doing:
if(!(total.text==totalTextCache && divisions.text==divisionsTextCache))
Because I didn't actually want to copy the NSString
s, but just check if they'd changed (and therefore the reference would have changed, this works. The bad code ran fine in the 2.2.1 runtime because the old reference could still have it's hash property checked and compared by isEqual
.