【问题标题】:Why does iPhone 5.1 Simulator give less debugging info than 4.3 Simulator?为什么 iPhone 5.1 Simulator 提供的调试信息比 4.3 Simulator 少?
【发布时间】:2012-07-24 12:10:33
【问题描述】:

在我的代码中,我将 NSNumber 分配给 NSString 时犯了一些错误:

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

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

在这种情况下,我是否必须在 5.1 模拟器中配置一些设置才能使其像 4.3 一样工作?

【问题讨论】:

  • 将其表述为:“为什么 iPhone 5.1 模拟器提供的调试信息比 4.3 模拟器少?”
  • @FabienB 感谢您重新提出我的问题。

标签: ios debugging ios-simulator crash-reports


【解决方案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 多一点的东西。

【讨论】:

  • 非常感谢。奇迹般有效! (只是想知道为什么这不是默认设置。)
【解决方案2】:

5.1 模拟器有什么用?

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

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

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

【讨论】:

  • 简而言之,信号 SIGABRT,将一行指向 main.m 和 -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0x8e5fe70 而没有指向我的代码中的任何地方。这与 4.3 模拟器不同,它完全指向我在问题中发布的行。
  • 我认为使用调试信息的重点是我们不知道首先应该在代码中的哪个位置使用@try@catch
  • 另外,try and catch 是资源密集型的。
猜你喜欢
  • 2011-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-01
  • 1970-01-01
  • 2012-09-15
  • 1970-01-01
相关资源
最近更新 更多