经过一段时间后,我发现无法识别的选择器被发送到实例异常.当我得到这个,我想跳过它,我的应用程序应该工作.
但是我不知道该怎么抓.因为这没有抓住:
@property(nonatomic,retain) UIButton *button;
@try{
if(button.currentBackgroundImage == nil){//rises exception
}
}@catch(NSException *e){
}
Run Code Online (Sandbox Code Playgroud)
我怎么能处理这个?
谢谢.
我经常使用和查看的技术是:检查对象是否响应选择器,而不是捕获异常:
if(![button respondsToSelector:@selector(currentBackgroundImage)] || button.currentBackgroundImage == nil) {
// do your thing here...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1585 次 |
| 最近记录: |