2012-07-24 22 views
1

某處在我的代碼,我被分配的NSNumber到的NSString做了一些錯誤:爲什麼iPhone 5.1模擬器比4.3模擬器提供更少的調試信息?

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

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

當在上面的點的應用程序崩潰,5.1模擬器並沒有表現出什麼樣線的具體信息我代碼導致崩潰。但是,4.3模擬器呢!

在這種情況下,我是否必須在5.1模擬器中配置一些設置才能讓它工作得像4.3?

+0

將它理解爲:「爲什麼iPhone 5.1模擬器比4.3模擬器提供更少的調試信息?」 – FabienB 2012-07-24 13:05:37

+0

@FabienB感謝您對我的問題重新措詞。 – 2012-07-24 13:13:40

回答

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多一點。

+0

非常感謝。奇蹟般有效! (只是想知道爲什麼這不是默認設置。) – 2012-07-24 13:39:58

0

你用5.1模擬器得到了什麼?

爲了防止這樣的運行時錯誤,你可以封裝與@try {} @catch {}或分配前檢查對象:

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

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

簡而言之,信號SIGABRT,指向一行main.m和 - [__ NSCFNumber isEqualToString:]:無法識別的選擇器發送到實例0x8e5fe70,沒有指向我的代碼中的任何地方。這與4.3模擬器不同,它恰好指向我在問題中發佈的行。 – 2012-07-24 13:08:46

+0

我認爲使用調試信息的重點是我們不知道代碼中的位置,我們應該首先使用'@ try'和'@ catch'。 – 2012-07-24 13:10:58

+0

另外,嘗試和捕獲是資源密集型的。 – jdog 2012-07-24 14:46:40