开发者

UITextField catching textFieldDidBeginEditing event causes EXC_BAD_ACCESS in main.m

开发者 https://www.devze.com 2023-02-23 05:26 出处:网络
This is mystifying. 开发者_StackOverflow中文版 My view controller implements the UITextFieldDelegate protocol in the .h file, and in the .mm file, I have

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消