在 iOS9 中,我的应用程序 SWPi 在 main.m 中崩溃:
#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = 0;
@try
{ NSLog(@"MAIN:");
retVal = UIApplicationMain(argc, argv, nil, nil);
}
@catch (NSException *exception)
{ NSLog(@"CRASH: %@", exception);
NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}
@finally
{ [pool release];
}
return retVal;
}
追踪:
2015-09-19 12:31:57.197 SWPi[441:79241] MAIN:
2015-09-19 12:31:57.533 SWPi[441:79241] CRASH: *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
2015-09-19 12:31:57.550 SWPi[441:79241] Stack Trace: (
0 CoreFoundation 0x22de96a3 <redacted> + 150
1 libobjc.A.dylib 0x34762e17 objc_exception_throw + 38
2 Foundation 0x23b69903 <redacted> + 110
3 Foundation 0x23b69abf <redacted> + 442
4 Foundation 0x23b3c9c9 <redacted> + 3764
5 Foundation 0x23b3ba6d <redacted> + 276
6 UIKit 0x27332f57 <redacted> + 1110
7 UIKit 0x27334f1d <redacted> + 196
8 UIKit 0x27143d19 <redacted> + 48
9 UIKit 0x26f1f34d <redacted> + 260
10 UIKit 0x27142d61 <redacted> + 1232
11 UIKit 0x27155db9 <redacted> + 36
12 UIKit 0x271403cf <redacted> + 134
13 FrontBoardServices 0x2ad82ccf <redacted> + 230
14 FrontBoardServices 0x2ad82fc1 <redacted> + 48
15 CoreFoundation 0x22dacc3f <redacted> + 14
16 CoreFoundation 0x22dac82d <redacted> + 452
17 CoreFoundation 0x22daab9b <redacted> + 794
18 CoreFoundation 0x22cfe249 CFRunLoopRunSpecific + 520
19 CoreFoundation 0x22cfe035 CFRunLoopRunInMode + 108
20 UIKit 0x26f18b2d <redacted> + 524
21 UIKit 0x26f138a9 UIApplicationMain + 144
22 SWPi 0x00015f6f main + 182
23 libdyld.dylib 0x34eae873 <redacted> + 2
)
在 iOS8 下一切正常。 哪里可能有问题?
为所有异常插入断点后调试:
2015-09-19 13:35:16.322 SWPi[454:85641] MAIN:
(lldb) bt
* thread #1: tid = 0x14e89, 0x34762df0 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x34762df0 libobjc.A.dylib`objc_exception_throw
frame #1: 0x22d03d7e CoreFoundation`-[__NSArrayM insertObject:atIndex:] + 622
frame #2: 0x26fe40d4 UIKit`-[UINavigationController _navigationItems] + 240
frame #3: 0x272181e6 UIKit`-[UINavigationController initWithCoder:] + 886
frame #4: 0x23b3c630 Foundation`_decodeObjectBinary + 2844
frame #5: 0x23b3ba6c Foundation`_decodeObject + 276
frame #6: 0x271ba5cc UIKit`-[UINavigationBar initWithCoder:] + 404
frame #7: 0x23b3c630 Foundation`_decodeObjectBinary + 2844
frame #8: 0x23b3ba6c Foundation`_decodeObject + 276
frame #9: 0x271b6bfe UIKit`-[UINavigationItem initWithCoder:] + 734
frame #10: 0x23b3c630 Foundation`_decodeObjectBinary + 2844
frame #11: 0x23b3ba6c Foundation`_decodeObject + 276
frame #12: 0x271fa904 UIKit`-[UIViewController initWithCoder:] + 460
frame #13: 0x27333ce2 UIKit`-[UIClassSwapper initWithCoder:] + 218
frame #14: 0x23b3c630 Foundation`_decodeObjectBinary + 2844
frame #15: 0x23b3ba6c Foundation`_decodeObject + 276
frame #16: 0x273339f0 UIKit`-[UIRuntimeConnection initWithCoder:] + 160
frame #17: 0x2733404c UIKit`-[UIRuntimeEventConnection initWithCoder:] + 52
frame #18: 0x23b3c630 Foundation`_decodeObjectBinary + 2844
frame #19: 0x23b427d2 Foundation`-[NSKeyedUnarchiver _decodeArrayOfObjectsForKey:] + 1378
frame #20: 0x23adf2da Foundation`-[NSArray(NSArray) initWithCoder:] + 318
frame #21: 0x23b3c630 Foundation`_decodeObjectBinary + 2844
frame #22: 0x23b3ba6c Foundation`_decodeObject + 276
frame #23: 0x27332f56 UIKit`-[UINib instantiateWithOwner:options:] + 1110
frame #24: 0x27334f1c UIKit`-[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 196
frame #25: 0x27143d18 UIKit`-[UIApplication _loadMainNibFileNamed:bundle:] + 48
frame #26: 0x26f1f34c UIKit`-[UIApplication _loadMainInterfaceFile] + 260
frame #27: 0x27142d60 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1232
frame #28: 0x27155db8 UIKit`__84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke3181 + 36
frame #29: 0x271403ce UIKit`-[UIApplication workspaceDidEndTransaction:] + 134
frame #30: 0x2ad82cce FrontBoardServices`-[FBSSerialQueue _performNext] + 230
frame #31: 0x2ad82fc0 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 48
frame #32: 0x22dacc3e CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
frame #33: 0x22dac82c CoreFoundation`__CFRunLoopDoSources0 + 452
frame #34: 0x22daab9a CoreFoundation`__CFRunLoopRun + 794
frame #35: 0x22cfe248 CoreFoundation`CFRunLoopRunSpecific + 520
frame #36: 0x22cfe034 CoreFoundation`CFRunLoopRunInMode + 108
frame #37: 0x26f18b2c UIKit`-[UIApplication _run] + 524
frame #38: 0x26f138a8 UIKit`UIApplicationMain + 144
* frame #39: 0x00074f8e SWPi`main(argc=1, argv=0x00920b54) + 182 at main.m:7
* 编辑
问题出在主 xib 上。 iOS4-8忽略它,iOS9不。
在文本模式下:
<navigationItem key="navigationItem" title="Item" id="R9S-B3-9Aq"/>
这个item在父 Controller 的Outlets中的Xcode中是可见的,但是在文本模式下xib中没有outlet reference。 在 Xcode 中,这个 socket 和其他 socket 一样是灰色的,我无法删除它。 在文本模式下删除 xib 的这一行后,parent *.m & *.h app 中的 outlet & references 运行正常。
最佳答案
正如其他人所说,您正在将一个 nil 对象插入到代码中某处的数组中。调试器并不擅长报告发生错误的源代码行。它可能显示为在 main.m 中,但这显然是错误的。
尝试在所有 Objective-C 异常上设置一个全局断点。这通常会导致 Xcode 向您显示导致崩溃的实际行。 (不需要在 main.m 中使用 try/catch,它甚至可能会混淆。)
好的,我想我看到了您在回答中所做的更改。您添加了第二个堆栈跟踪。
您的崩溃日志是否仍然声称错误发生在 main.m 中?从第二个崩溃日志来看,似乎在为初始 View Controller 打开 View Controller 场景时可能存在问题。在堆栈跟踪中有对 _runWithMainScene:transitionContext:completion 的引用,然后是 -[UIApplication _loadMainNibFileNamed:bundle:](内部 Storyboard 实际上包含 nibfile。
我的猜测是您的 Storyboard 中的 Root View Controller 存在一些细微的损坏。还有对 -[UINavigationController _navigationItems] 的调用。这表明您的 Root View Controller 中的导航项可能存在问题。
我了解到您的应用使用导航 Controller 作为您的 Root View Controller ?
关于iOS9 崩溃 : *** -[__NSArrayM insertObject:atIndex:]: object cannot be nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32667258/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
当我在Rails控制台中按向上或向左箭头时,出现此错误:irb(main):001:0>/Users/me/.rvm/gems/ruby-2.0.0-p247/gems/rb-readline-0.4.2/lib/rbreadline.rb:4269:in`blockin_rl_dispatch_subseq':invalidbytesequenceinUTF-8(ArgumentError)我使用rvm来管理我的ruby安装。我正在使用=>ruby-2.0.0-p247[x86_64]我使用bundle来管理我的gem,并且我有rb-readline(0.4.2)(人们推荐的最少
这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下
我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的
1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里
print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上
代码:threads=[]Thread.abort_on_exception=truebegin#throwexceptionsinthreadssowecanseethemthreadseputs"EXCEPTION:#{e.inspect}"puts"MESSAGE:#{e.message}"end崩溃:.rvm/gems/ruby-2.1.3@req/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:478:inload_missing_constant':自动加载常量MyClass时检测到循环依赖稍加研究后,
当我将IO::popen与不存在的命令一起使用时,我在屏幕上打印了一条错误消息:irb>IO.popen"fakefake"#=>#irb>(irb):1:commandnotfound:fakefake有什么方法可以捕获此错误,以便我可以在脚本中进行检查? 最佳答案 是:升级到ruby1.9。如果您在1.9中运行它,则会引发Errno::ENOENT,您将能够拯救它。(编辑)这是在1.8中的一种hackish方式:error=IO.pipe$stderr.reopenerror[1]pipe=IO.popen'qwe'#
当我尝试使用“套接字”库中的方法“read_nonblock”时出现以下错误IO::EAGAINWaitReadable:Resourcetemporarilyunavailable-readwouldblock但是当我通过终端上的IRB尝试时它工作正常如何让它读取缓冲区? 最佳答案 IgetthefollowingerrorwhenItrytousethemethod"read_nonblock"fromthe"socket"library当缓冲区中的数据未准备好时,这是预期的行为。由于异常IO::EAGAINWaitReadab
任何人都可以解释为什么当对方法的调用看起来像这样时我可能会看到这个堆栈(由HTTParty::post请求引起):beginresponse=HTTParty::post(url,options)rescuelogger.warn("Couldnotpostto#{url}")rescueTimeout::Errorlogger.warn("Couldnotpostto#{url}:timeout")end堆栈:/usr/local/lib/ruby/1.8/timeout.rb:64:in`timeout'/usr/local/lib/ruby/1.8/net/protocol.rb