我在third party component中發生崩潰。很顯然,這是我必須研究的一個潛在原因。但爲了使這更強大,同時我想用@try @catch
塊來包圍崩潰的呼叫。Will @try @catch會爲SIGSEGV/SEGV_ACCERR工作
我無法複製到目前爲止的崩潰,所以我不能確定@try @catch
是否會在這種情況下工作。我的問題是@try
和@catch
通常適用於哪種類型的案例。
Hardware Model: iPhone3,1
Process: MyApp [2084]
Path: /var/mobile/Applications/8B400A7D-88E7-4319-9C5D-F7E72DE8D960/MyApp.app/MyApp
Identifier: com.company.MyApp-Snapshot
Version: 7.2
Code Type: ARM
Parent Process: launchd [1]
Date/Time: 2012-09-07 14:04:14 +0000
OS Version: iPhone OS 5.1.1 (9B206)
Report Version: 104
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0xe1088602
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x35260f78 objc_msgSend + 15
1 UIKit 0x312363d7 -[UIView(Hierarchy) superview] + 50
*************************************************************************** |<---- UIView *superview = self.superview;
2 MyApp 0x000238f9 -[MBProgressHUD deviceOrientationDidChange:] (MBProgressHUD.m:622)
***************************************************************************
3 Foundation 0x37dc64ff __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 18
4 CoreFoundation 0x3752d547 ___CFXNotificationPost_block_invoke_0 + 70
5 CoreFoundation 0x374b9097 _CFXNotificationPost + 1406
6 Foundation 0x37d3a3eb -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
7 UIKit 0x3123adeb -[UIDevice setOrientation:animated:] + 214
8 UIKit 0x3123616f -[UIApplication handleEvent:withNewEvent:] + 2718
9 UIKit 0x31235567 -[UIApplication sendEvent:] + 54
10 UIKit 0x31234f3b _UIApplicationHandleEvent + 5826
11 GraphicsServices 0x33c7722b PurpleEventCallback + 882
12 CoreFoundation 0x37535523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
13 CoreFoundation 0x375354c5 __CFRunLoopDoSource1 + 140
14 CoreFoundation 0x37534313 __CFRunLoopRun + 1370
15 CoreFoundation 0x374b74a5 CFRunLoopRunSpecific + 300
16 CoreFoundation 0x374b736d CFRunLoopRunInMode + 104
17 GraphicsServices 0x33c76439 GSEventRunModal + 136
18 UIKit 0x31263cd5 UIApplicationMain + 1080
19 MyApp 0x00003643 main (main.m:16)
更新:ApparentlySIGSEGV
不是你能趕上,但通過訪問內存是無效導致異常。從我的角度來看,儘管找到問題的根源顯然是解決問題的更好方法,但能夠抓住這種例外仍然很方便。
我會建議,要麼固定'MBProgressHUD'中的錯誤,要麼移動到['SVProgressHUD'](https://github.com/samvermette/SVProgressHUD),它更加穩定並且仍然由開發人員更新。 – rckoenes