Xcode 错误线程 1:EXC_BREAKPOINT(代码=1,子代码=0x1001f276588)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37555837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode error Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1001f276588)
提问by atirit
I get the titular error when running my project on an actual device. Sometimes the subcode varies. I don't have ANY breakpoints. I checked. Trust me on that.
在实际设备上运行我的项目时出现名义错误。有时子代码会有所不同。我没有任何断点。我检查了。相信我。
Here are my files. This error happens on launch.
这是我的文件。此错误发生在启动时。
What can I do to fix this? Thanks in advance!
我能做些什么来解决这个问题?提前致谢!
EDIT: fatal error: unexpectedly found nil while unwrapping an Optional value
is printed to the console.
编辑:fatal error: unexpectedly found nil while unwrapping an Optional value
打印到控制台。
回答by Robski18
I think the error is in this part:
我认为错误在这部分:
let dir = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true).first
let filePath = NSURL(fileURLWithPath: dir!).URLByAppendingPathComponent("file.txt")
It is forced to unwrap "dir", which is probably not available in this case on your actual device. This causes the immediate crash.
它被迫解开“dir”,在这种情况下,这可能在您的实际设备上不可用。这会导致立即崩溃。