This is mystifying.
开发者_StackOverflow中文版My view controller implements the UITextFieldDelegate protocol in the .h file, and in the .mm file, I have
myTextField.delegate = self
And my textFieldDidBeginEditing event is simply a NSLog message.
When I run my program and set focus on myTextField, I get a EXC_BAD_ACCESS error.
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil); // EXC_BAD_ACCESS
[pool release];
return retVal;
}
It must be an obvious blunder I have somewhere, but it's been troubling me all night. Anybody knows why? And how I can catch the begin-edit event of a textField?
Foremost, Xcode 4 changed the behavior of the debugger. On the debugger panel on the left, there should be a slider all the way at the bottom - showing you MORE or LESS stack frames. You're showing the top stack frame (UIApplication) -- chances are if you slide that slider you'll see more of an idea of where you are crashing.
Also, if it's EXC_BAD_ACCESS, have you turned on NSZombieEnabled = YES as an environment variable to catch what is being over-released? Usually it's a memory problem.
精彩评论