为什么iPhone 5.1模拟器提供的调试信息少于4.3模拟器?

时间:2012-07-24 12:10:34

标签: ios debugging ios-simulator crash-reports

在我的代码中,我通过将NSNumber分配给NSString来做错了一些错误:

self.totalLikesLabel.text=[user objectForKey:@"totalLikes"];

Comparison of crash information between 5.1 Simulator (top) and 4.3 Simulator (bottom)

当应用程序在上面的位置崩溃时,5.1模拟器没有显示我的代码中哪些行导致崩溃的具体信息。但是,4.3 Simulator做了!

我是否必须在5.1 Simulator中配置一些设置才能让它在这种情况下像4.3那样工作?

2 个答案:

答案 0 :(得分:1)

1.Go to the breakpoint navigator (left navigation panel 6th one from the left).
2. Click the "+" button at the bottom
3. Select Exception Breakpoint
4. Leave Exception Breakpoint checked
5. In the Exception: field select "Objective-C"
6. In the Break: field select "On Throw"
7. Leave Action: alone (unless you want it to do something)
8. Leave Option: **unchecked**
9. Click "Done"

这应该让你看到比SIGABRT更多的东西。

答案 1 :(得分:0)

使用5.1模拟器你会得到什么?

为防止此类运行时错误,您可以使用@try {} @catch {}封装它,或者在分配之前检查对象:

id s = [user objectForKey:@"totalLikes"];

if ([s isKindOfClass [NSString class]]) ...