NSArray *array1=@[@"1",@"2"]; NSString *s1=array1[2];
這個是常常遇到的問題c++
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 2 beyond bounds [0 .. 1]' *** First throw call stack: ( 0 CoreFoundation 0x034d1a14 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x02b54e02 objc_exception_throw + 50 2 CoreFoundation 0x033a9a4e -[__NSArrayI objectAtIndex:] + 206 3 ScanCode 0x000bca53 -[NSArray(Debug) objectAtIndexDebug:] + 691 4 CoreFoundation 0x034161d8 -[NSArray objectAtIndexedSubscript:] + 40 5 ScanCode 0x00162dcb -[AppDelegate application:didFinishLaunchingWithOptions:] + 827 6 UIKit 0x00dee172 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 337 7 UIKit 0x00def5a0 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3863 8 UIKit 0x00df6cd6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1989 9 UIKit 0x00e1bee5 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3218 + 68 10 UIKit 0x00df3966 -[UIApplication workspaceDidEndTransaction:] + 163 11 FrontBoardServices 0x07ca9c76 __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71 12 FrontBoardServices 0x07ca974d __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54 13 FrontBoardServices 0x07cc7173 -[FBSSerialQueue _performNext] + 184 14 FrontBoardServices 0x07cc75aa -[FBSSerialQueue _performNextFromRunLoopSource] + 52 15 FrontBoardServices 0x07cc68a6 FBSSerialQueueRunLoopSourceHandler + 33 16 CoreFoundation 0x033eb6ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15 17 CoreFoundation 0x033e138b __CFRunLoopDoSources0 + 523 18 CoreFoundation 0x033e07a8 __CFRunLoopRun + 1032 19 CoreFoundation 0x033e00e6 CFRunLoopRunSpecific + 470 20 CoreFoundation 0x033dfefb CFRunLoopRunInMode + 123 21 UIKit 0x00df3206 -[UIApplication _run] + 540 22 UIKit 0x00df8bfa UIApplicationMain + 160 23 ScanCode 0x001657ea main + 138 24 libdyld.dylib 0x0427ea21 start + 1 25 ??? 0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)
在調試的po命令裏面輸入 image lookup -a 內存地址 就能夠找到報錯代碼的位置數組
(lldb) image lookup -a 0x00162dcb Address: ScanCode[0x000a8dcb] (ScanCode.__TEXT.__text + 681771) Summary: ScanCode`-[AppDelegate application:didFinishLaunchingWithOptions:] + 827 at AppDelegate.m:34
就知道是在AppDelegate的34行瀏覽器
能夠用symbolic斷點viewDidLoad這樣在每一個控制器返回都會停一下網絡
結合NSLog宏輸出當前的文件名和行數來定位會變得很容易 app
view debug工具
必要時給view加背景色oop
檢查網址和參數測試
Charles 分析網絡請求的內容spa
http 測試工具debug
若是是get請求,有時候能夠直接用瀏覽器打開連接進行測試
參考官方說明或者其它人的demo和教程
參考官方的demo
儘可能描述清楚,發帖求助,而後暫時不處理
由於毫無頭緒還在繼續研究是浪費時間的行爲,除非你的項目其它部分都已經完成。或者你在緊急修復bug,不然都不該該在沒有頭緒的狀況下處理bug