App crashes with exc_bad_access when I type in the textfield


I am running through the IOS emulator and when I start to type into the text field the application crashes, highlighting the line that starts “int retVal” in the code below; the error message is “Thread 1: Program received signal : EXC_BAD_ACCESS”. Initially, I thought I had typed something incorrectly, but I downloaded the examples for the book and I get the same problem with that - does the Whereami.h field that is bound to the text field need initialising somewhere?

I am using the following:

[ul]O/S: OSX Lion 10.7.2
XCode Version 4.2[/ul]

#import <UIKit/UIKit.h>

int main(int argc, char *argv[])
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;


Can you check out the stack trace in the Debug Navigator?

It is possible that this is a bug in Xcode/Simulator that people have been seeing.


All I get in the debug navigator is the below output.

GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug  8 20:32:45 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".Attaching to process 771.
sharedlibrary apply-load-rules all
Current language:  auto; currently objective-c


My apologies for the previous un-helpful post, I am new to the Apple world and have not got the hang of XCode yet - I found out how to get the backtrace in the debugger and that yields the below output.

Based on what you said about a bug with the XCode/Simulator I did a bit of digging on the web and that led me to this post, which does confirm an issue with the simulator and when I turn off Auto Correction on the simulator, as suggested, everything works fine!

Thanks for your help - I’m finding your book invaluable :smiley:

(gdb) bt #0 0x011ea000 in objc_assign_ivar () #1 0x03b4dc34 in -[AppleSpell init] () #2 0x0056c538 in -[UITextChecker _checker] () #3 0x0056dde9 in -[UITextChecker checkSpellingOfString:startingAt:language:wrap:correction:] () #4 0x0c1fd725 in TIInputManagerZephyr::lookup_spellcheck_candidates () #5 0x0c1fd3f3 in TIInputManagerZephyr::lookup_static_dynamic_candidates () #6 0x0c1fab2b in TIInputManager::lookup () #7 0x0c1fae18 in TIInputManager::autocorrection () #8 0x0c21206b in -[TIKeyboardInputManagerZephyr autocorrection] () #9 0x00354be8 in -[UIKeyboardImpl generateCandidatesWithCompletions:] () #10 0x00354c3b in -[UIKeyboardImpl generateCandidates] () #11 0x00361a23 in -[UIKeyboardImpl addInputString:fromVariantKey:] () #12 0x0036371b in -[UIKeyboardImpl handleKeyEvent:] () #13 0x0048f2ee in -[UIKeyboardLayoutStar sendStringAction:forKey:] () #14 0x00493d19 in -[UIKeyboardLayoutStar touchUp:] () #15 0x00370da2 in -[UIKeyboardLayout touchesEnded:withEvent:] () #16 0x0023dded in -[UIWindow _sendTouchesForEvent:] () #17 0x0021ec37 in -[UIApplication sendEvent:] () #18 0x00223f2e in _UIApplicationHandleEvent () #19 0x01f05992 in PurpleEventCallback () #20 0x00fa8944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ () #21 0x00f08cf7 in __CFRunLoopDoSource1 () #22 0x00f05f83 in __CFRunLoopRun () #23 0x00f05840 in CFRunLoopRunSpecific () #24 0x00f05761 in CFRunLoopRunInMode () #25 0x01f041c4 in GSEventRunModal () #26 0x01f04289 in GSEventRun () #27 0x00227c93 in UIApplicationMain () #28 0x000022ed in main (argc=1, argv=0xbffff644) at /Users/richard/Development/XCode/Whereami/Whereami/main.m:6


This is actually an error with Apple. Go into your Settings on the simulator (the Settings app on the sim, that is) and turn off auto correction.