【ios 异常FAQ】unrecognized selector sent to instance
2014-02-27 14:21
639 查看
unrecognized selector sent to instance 异常,一般是因为发送到消息对象被释放或者方法参数不匹配导致,因为@selector(XXX)在编译的时候没有明确现在参数类型;
一般在xcode中如何调试的时候直接定位到代码行,先设置 NSZombieEnabled为true,重新编译启动会直接定位到行。
eg:
一般在xcode中如何调试的时候直接定位到代码行,先设置 NSZombieEnabled为true,重新编译启动会直接定位到行。
eg:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Show" style:0 target:self action:@selector(toggleAuthCodeBox:)]; - (void)toggleAuthCodeBox:(UIButton *)button //这里应该为UIBarButtonItem,被强转,然后因为它没有setTitle:forState:方法导致; { self.loginBox.authCodeBoxVisible = !self.loginBox.authCodeBoxVisible; [button setTitle:self.loginBox.authCodeBoxVisible ? @"Hide" : @"Show" forState:UIControlStateNormal]; }正确的这么改:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Show" style:0 target:self action:@selector(toggleAuthCodeBox:)]; - (void)toggleAuthCodeBox:(UIBarButtonItem *)button //这里改为UIBarButtonItem { self.loginBox.authCodeBoxVisible = !self.loginBox.authCodeBoxVisible; [button setTitle:self.loginBox.authCodeBoxVisible ? @"Hide" : @"Show"]; //这里改 }
相关文章推荐
- iOS开发——异常:[__NSCFNumber length]: unrecognized selector sent to instance
- IOS TableView 报异常,unrecognized selector sent to instance(个人)
- iOS开发之Debug之unrecognized selector sent to instancexxx
- [ios] tableView:cellForRowAtIndexPath: unrecognized selector sent to instance
- IOS微信API异常:unrecognized selector sent to instance 0x17005c9b0'
- reason: '-[__NSCFNumber rangeOfCharacterFromSet:]: unrecognized selector sent to instance --iOS开发之崩溃
- ios- -[__NSCFType invalidate]: unrecognized selector sent to instance 0x18894a30错误随笔
- iOS中的crash防护(一)unrecognized selector sent to instance
- 有关unrecognized selector sent to instance xxxxxxxxx的异常崩溃
- iOS错误处理之[__NSArrayM 某一方法名:]: unrecognized selector sent to instance
- iOS开发中, '-[__NSCFConstantString size]: unrecognized selector sent to instance 0x10abccc00'
- iOS中变量命名引起的错误错误: [UILabel copyWithZone:]: unrecognized selector sent to instance
- [iOS] Error Fixed : [__NSArrayI addObject:]: unrecognized selector sent to instance
- 【iOS】使用storyboard界面跳转报错:unrecognized selector sent to instance 0x7
- iOS nil、Nil、NULL、NSNull的区别(null)与<null>的处理: -[NSNull length]: unrecognized selector sent to instance
- [iOS] Error Fixed : [__NSArrayI addObject:]: unrecognized selector sent to instance
- iOS reason: '-[__NSArrayM objectForKeyedSubscript:]: unrecognized selector sent to instance 0x60800
- iOS报错[__NSCFNumber length]: unrecognized selector sent to instance
- IOS微信API异常:unrecognized selector sent to instance 0x17005c9b0'
- iOS开发之 [NSNull length]:unrecognized selector sent to instance