objective-c - 为什么在不设置断点的情况下程序会暂停而不崩溃?

标签 objective-c ios xcode

我有一个项目只是暂停,并且不会崩溃。它在该组的最后一行暂停:

 NSLog(@"%@", nibOptions);
 NSLog(@"%@", self.nibName);
 NSLog(@"%@", self.nibBundle);

 [self.nibBundle loadNibNamed:self.nibName owner:self options:nibOptions];

暂停之前的 NSLog 看起来完全合理。我认为一切都连接正确。但显然有些不对劲。关于排除不提供任何信息的暂停的任何建议?没有设置断点。谢谢。 (Xcode 4.2)

编辑:我要补充一点,该应用程序位于前面,然后移动到 Xcode 窗口后面。 Nib / View 未加载。

编辑:这是崩溃日志(继续暂停后):

#0  0x90160332 in __kill ()
#1  0x9015f932 in kill$UNIX2003 ()
#2  0x013e136b in CFHash ()
#3  0x01493c04 in __CFDictionaryStandardHashKey ()
#4  0x013e9114 in CFBasicHashFindBucket ()
#5  0x013e8ad5 in CFDictionaryGetValue ()
#6  0x00588ba4 in +[UIProxyObject mappedObjectForCoder:withIdentifier:] ()
#7  0x00588c9d in -[UIProxyObject initWithCoder:] ()
#8  0x00687fa2 in UINibDecoderDecodeObjectForValue ()
#9  0x006876b7 in -[UINibDecoder decodeObjectForKey:] ()
#10 0x00588ead in -[UIRuntimeConnection initWithCoder:] ()
#11 0x00589629 in -[UIRuntimeEventConnection initWithCoder:] ()
#12 0x00687fa2 in UINibDecoderDecodeObjectForValue ()
#13 0x006879af in UINibDecoderDecodeObjectForValue ()
#14 0x006876b7 in -[UINibDecoder decodeObjectForKey:] ()
#15 0x00588305 in -[UINib instantiateWithOwner:options:] ()
#16 0x0058a010 in -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] ()
#17 0x00002fc5 in -[P3ViewController loadView] at /Users/bryanhanson/Desktop/NastyMarty/P3/Classes/P3ViewController.m:158
#18 0x004305cb in -[UIViewController view] ()
#19 0x00390a73 in -[UIWindow addRootViewControllerViewIfPossible] ()
#20 0x00390ce2 in -[UIWindow _setHidden:forced:] ()
#21 0x00390ea8 in -[UIWindow _orderFrontWithoutMakingKey] ()
#22 0x00397d9a in -[UIWindow makeKeyAndVisible] ()
#23 0x0000297e in -[P3AppDelegate application:didFinishLaunchingWithOptions:] ()
#24 0x003689d6 in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
#25 0x003698a6 in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
#26 0x00378743 in -[UIApplication handleEvent:withNewEvent:] ()
#27 0x003791f8 in -[UIApplication sendEvent:] ()
#28 0x0036caa9 in _UIApplicationHandleEvent ()
#29 0x01bc7fa9 in PurpleEventCallback ()
#30 0x014a51c5 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#31 0x0140a022 in __CFRunLoopDoSource1 ()
#32 0x0140890a in __CFRunLoopRun ()
#33 0x01407db4 in CFRunLoopRunSpecific ()
#34 0x01407ccb in CFRunLoopRunInMode ()
#35 0x003692a7 in -[UIApplication _run] ()
#36 0x0036aa9b in UIApplicationMain ()
#37 0x00002458 in main ()

最佳答案

窗口移动到 Xcode 后面,因为当您的应用程序暂停/崩溃时它会获得焦点。并且 View 不会加载,因为您刚刚调用了 loadnib 或尚未调用(取决于应用程序暂停的行)。

现在,正如您所说,如果您恢复运行您的应用程序就会死掉,那么这是崩溃而不是暂停。

尝试验证 nib 名称和选项是否正确,以及 xib 文件是否确实存在并与应用程序捆绑在一起。

编辑

尝试接受的答案中的解决方案 here .

It's crashing in NibDecoder, i.e. when loading your XIB files. You probably have a reference in there to an object or property that doesn't exist or isn't initialized.

OP 的结论:

I built everything up again from scratch in my custom controller object and i've bypassed what was killing me last time. Every single change I made I compiled and ran in the iPhone sim to make sure I didn't trip myself up. I think my connections to my Controller object must have been incorrect and I was doing something else. So lesson learned is compile and test a lot when doing IB layouts... not just when using Xcode!

因此,请尝试像他一样:验证 xib 文件中的连接,或者如果可能的话,重新启动它并逐步添加内容以查看导致崩溃的原因。

关于objective-c - 为什么在不设置断点的情况下程序会暂停而不崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9337944/

相关文章:

ios - Objective C Google Maps API 公钥函数

iphone - 停止 MKMapview 的用户位置更新(蓝点)

jquery - jQuery:请求全屏在iPhone,iPad上不起作用

xcode - 表格 View 为空时如何显示标签

ios - 有没有办法检测屏幕键盘上的触摸?

ios - 求助 '@property (nonnull)' 这是什么?

objective-c - 如何像事件监视器一样以编程方式检查 Mac 上的可用系统内存?

objective-c - 删除所有引用后如何删除卡在 Nib 中的图像

ios - Appium iOS Safari 打开新标签,接受提醒并在两个标签之间切换

工具栏中条形按钮项底部的 Swift 条