我的应用程序是随机的(有时它确实,有时它不会)崩溃:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
*** First throw call stack:
(
0 CoreFoundation 0x000000010988ec65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010b63bbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000109793af8 -[__NSDictionaryM setObject:forKey:] + 968
3 MultipeerConnectivity 0x00000001096e32e2 -[MCNearbyServiceBrowser netServiceBrowser:didFindService:moreComing:] + 251
4 CFNetwork 0x000000010c2ca2dd -[NSNetServiceBrowser _dispatchCallBack:flags:error:] + 968
5 CFNetwork 0x000000010c217fe2 _ZL14_BrowserCancelP21__CFNetServiceBrowser + 133
6 CoreFoundation 0x00000001097c2431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
7 CoreFoundation 0x00000001097b82fd __CFRunLoopDoSources0 + 269
8 CoreFoundation 0x00000001097b7934 __CFRunLoopRun + 868
9 CoreFoundation 0x00000001097b7366 CFRunLoopRunSpecific + 470
10 GraphicsServices 0x000000010d1a3a3e GSEventRunModal + 161
11 UIKit 0x000000010a36f8c0 UIApplicationMain + 1282
12 MyApp 0x0000000109099137 main + 135
13 libdyld.dylib 0x000000010cccc145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
如何在Xcode中告诉哪一行代码或集合对象导致问题?
更新
我做了回答和评论建议,并在命令中添加了断点,现在,在错误之前,我得到了这个:
*** setObjectForKey:key不能为nil
4354859399
3534170
140567501647968
140567492355160
140567492355168
4354751672
4294967279
我仍然不知道这意味着什么...
答案 0 :(得分:4)
在Xcode的左侧面板中,转到“断点”标签,单击+
按钮并添加Exception Breakpoint
。它将捕获任何异常并告诉您它们发生的位置。